[jira] Commented: (JELLY-230) Problem with default namespace in imported scripts
[ http://issues.apache.org/jira/browse/JELLY-230?page=comments#action_12402283 ] Diogo Bacelar Quintela commented on JELLY-230: -- You could use the replaceNamespace tag.. x:replaceNamespace fromURI=dummy toURI= project name=${pom.artifactId} default=jar basedir=. target name=clean description=Clean up delete dir=$${defaulttargetdir}/ delete dir=$${distdir}/ /target /project /x:replaceNamespace It should work dispite i haven't tested. Problem with default namespace in imported scripts -- Key: JELLY-230 URL: http://issues.apache.org/jira/browse/JELLY-230 Project: Jelly Type: Bug Components: core / taglib.core Versions: 1.1 Environment: jelly-1.1-SNAPSHOT Reporter: Lukas Theussl Assignee: james strachan Priority: Critical I am trying to build Maven with jelly-1.1-SNAPSHOT from svn trunk because it contains a fix for a regression that has blocked us for a long time, see http://jira.codehaus.org/browse/MAVEN-1691 (gee, I wish I'd checked the svn archives earlier!). However, even though jelly-1.1-SNAPSHOT solves the above issue, it also leads to a whole bunch of test failures in several of our plugins. After some investigation I found that they all turn out to be due to the same cause, an apparent backwards incompatibility introduced in the fix for JELLY-213. I am not sure actually if this is a bug or the intended behavior, but it certainly breaks backwards compatibility. To illustrate the problem: in the ant plugin we use the following snippet to generate an ant build.xml file from a template: j:file name=build.xml prettyPrint=true j:import file=templates/build.jelly inherit=true/ /j:file where the template file build.jelly looks like this (simplified): j:jelly xmlns:ant=jelly:ant xmlns:j=jelly:core xmlns=dummy project name=${pom.artifactId} default=jar basedir=. target name=clean description=Clean up delete dir=$${defaulttargetdir}/ delete dir=$${distdir}/ /target /project /j:jelly Note the xmlns=dummy namespace declaration which is necessary to distinguish the default namespace of the template script from Maven's default namespace. Now with jelly-1.0, this works as expected, but with the current jelly-1.1-SNAPSHOT, I get: project xmlns=dummy name=test-maven-ant-plugin default=jar basedir=. target description=Clean up name=clean delete dir=${defaulttargetdir} /delete delete dir=${distdir} /delete /target project ie the dummy namespace declaration makes it into the top-level element of the generated file. This makes ant very unhappy when invoked on this build file... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JELLY-225) apt jelly tag library
[ http://issues.apache.org/jira/browse/JELLY-225?page=comments#action_12361188 ] Diogo Bacelar Quintela commented on JELLY-225: -- I haven't take the time to check it. It seems interesting although from you post. I've just a penny to add. XDoclet2 is a pretty good replacement for XDoclet that supports various scripting tools. Out of the box, there is jelly and velocity. Apt tag library, as any tag library, can easilly be used within XDoclet2 - http://xdoclet.codehaus.org/ Regards apt jelly tag library - Key: JELLY-225 URL: http://issues.apache.org/jira/browse/JELLY-225 Project: jelly Type: New Feature Components: submissions Reporter: Ryan Heaton Attachments: testBasicExample.jelly, testForAllTypesIncludeInterfaces.jelly This is a proposal for a new jelly tag library that provides an interface to the new Java 5 Annotation Processing Tool (apt) and its associated Mirror API (see http://java.sun.com/j2se/1.5.0/docs/guide/apt/index.html). From the official apt documentation: apt is a command-line utility for annotation processing. It includes a set of reflective APIs and supporting infrastructure to process program annotations (JSR 175). These reflective APIs provide a build-time, source-based, read-only view of program structure. They are designed to cleanly model the Java programming language's type system after the addition of generics (JSR 14). Developers who which to process Java source code are presently limited to working with the Mirror API directly. If, for example, a developer wished to generate an artifact such as an xml config file or another Java class must do so by writing to an instance of java.io.PrintWriter. As an admittedly impotent example, to generate a simple class that will print out all methods of all classes in a given source base, the developer would implement instances of com.sun.mirror.apt.AnnotationProcessorFactory and com.sun.mirror.apt.AnnotationProcessor that look something like this: package org.apache.commons.jelly.examples; import java.util.Collection; import java.util.Set; import java.util.Collections; import java.io.IOException; import java.io.PrintWriter; import com.sun.mirror.apt.AnnotationProcessorFactory; import com.sun.mirror.apt.AnnotationProcessor; import com.sun.mirror.apt.AnnotationProcessorEnvironment; import com.sun.mirror.declaration.AnnotationTypeDeclaration; import com.sun.mirror.declaration.TypeDeclaration; import com.sun.mirror.declaration.MethodDeclaration; public class ClassAndMethodPrinterAnnotationProcessorFactory implements AnnotationProcessorFactory { public CollectionString supportedOptions() { return Collections.EMPTY_LIST; } public CollectionString supportedAnnotationTypes() { return Collections.EMPTY_LIST; } public AnnotationProcessor getProcessorFor(SetAnnotationTypeDeclaration atds, AnnotationProcessorEnvironment env) { return new ClassAndMethodPrinterAnnotationProcessor(env); } private class ClassAndMethodPrinterAnnotationProcessor implements AnnotationProcessor { AnnotationProcessorEnvironment env; public ClassAndMethodPrinterAnnotationProcessor(AnnotationProcessorEnvironment env) { this.env = env; } public void process() { try { PrintWriter writer = env.getFiler().createSourceFile(org.apache.commons.jelly.examples.ClassAndMethodPrinter); writer.println(package org.apache.commons.jelly.examples;); writer.println(); writer.println(public class ClassAndMethodPrinter {); writer.println(); writer.println( public static void main(String[] args) {); for (TypeDeclaration typeDeclaration : env.getTypeDeclarations()) { writer.println(String.format(System.out.println(\Class: %s\);, typeDeclaration.getQualifiedName())); for (MethodDeclaration methodDeclaration : typeDeclaration.getMethods()) { writer.println(String.format( System.out.println(\Method: %s.%s\);, typeDeclaration.getQualifiedName(), methodDeclaration.getSimpleName())); } } writer.println( }); writer.println(); writer.println(}); } catch (IOException e) { throw new RuntimeException(e); } } } } Any Java programmer with a little bit of experience could testify that using a PrintWriter for large and complex output is significantly heavy and burdensome. To use a familiar paradigm in J2EE, nobody wants to use a Servlet's PrintWriter for outputting many large and complex html documents. For this reason, Java Server Pages (JSP) were created
[jira] Created: (JELLY-220) core:forEach doesn't use a nested context
core:forEach doesn't use a nested context - Key: JELLY-220 URL: http://issues.apache.org/jira/browse/JELLY-220 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela As said in summary, analising ForEachTag.java and a simple test (see below) this tags set's variables into current JellyContext, not using childContext. This could be another source for a memory leak, don't know for sure. JSTL states that a nested context should be used - this tag aims to be JSTL compliant. http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/forEach.html j:jelly xmlns:j=jelly:core a b j:forEach var=class1 items=${metadata} c${util.getName(class1)}/c /j:forEach c-out-of-context${util.getName(class1)}/c-out-of-context j:scope j:forEach var=class2 items=${metadata} d${util.getName(class2)}/d /j:forEach /j:scope d-out-of-context${util.getName(class2)}/d-out-of-context /b /a /j:jelly resulting in ?xml version=1.0 encoding=ISO-8859-1? a b cTestName/c c-out-of-contextTestName/c-out-of-context dTestName/d d-out-of-context/ /b /a -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JELLY-217) org.apache.commons.jelly.tags.xml.ElementTag small bug in output wrapper
[ http://issues.apache.org/jira/browse/JELLY-217?page=comments#action_12319355 ] Diogo Bacelar Quintela commented on JELLY-217: -- | to support | | x:element name=abc | x:commentmy comment/x:comment | /x:element | | to generate | abc | !-- my comment -- | /abc Right now is generating !-- my comment -- abc /abc org.apache.commons.jelly.tags.xml.ElementTag small bug in output wrapper Key: JELLY-217 URL: http://issues.apache.org/jira/browse/JELLY-217 Project: jelly Type: Bug Components: taglib.xml Reporter: Diogo Bacelar Quintela Priority: Trivial ElementTag has some small problems XMLOutput newOutput = new XMLOutput(output) { ... } Should include public void startPrefixMapping(String prefix, String uri) throws SAXException { initialize(); super. startPrefixMapping (prefix, uri); } startPrefixMapping is called automatically in startElement, so whenever a child script wants to start outputing, it will call startPrefixMapping before startElement (if needed). To attain correctness, we should override startPrefixMapping as it's done in startElement. Related, we could do the same for public void comment(char ch[], int start, int length) throws SAXException { initialize(); super. comment (ch, start, length); } to support x:element name=abc x:commentmy comment/x:comment /x:element to generate abc !-- my comment -- /abc -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Created: (JELLY-216) org.apache.commons.jelly.tags.xml.TransformTag fails testTransformSchematron in jdk1.3
org.apache.commons.jelly.tags.xml.TransformTag fails testTransformSchematron in jdk1.3 -- Key: JELLY-216 URL: http://issues.apache.org/jira/browse/JELLY-216 Project: jelly Type: Bug Components: taglib.xml Reporter: Diogo Bacelar Quintela Priority: Minor JDK 1.4 - All OK JDK 1.3 - Compiles OK but fails testTransformSchematron Runtime error at [junit] Testcase: testTransformSchematron(org.apache.commons.jelly.tags.xml.TestXMLTags): Caused an ERROR [junit] file:/C:/Work/commons-jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/transformSchematronExample.jelly:22:29: x:transform java.lang.NoSuchMethodError [junit] org.apache.commons.jelly.JellyTagException: file:/C:/Work/commons-jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/transformSchematronExample.jelly:22:29: x:transform java.lang.NoSuchMethodError [junit] at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:712) [junit] at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:282) [junit] at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) [junit] at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186) [junit] at org.apache.commons.jelly.tags.core.JellyTag.doTag(JellyTag.java:45) [junit] at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262) [junit] at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:706) [junit] at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:670) [junit] at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:579) [junit] at org.apache.commons.jelly.tags.xml.TestXMLTags.evaluteScriptAsText(TestXMLTags.java:309) [junit] at org.apache.commons.jelly.tags.xml.TestXMLTags.evaluteScriptAsText(TestXMLTags.java:283) [junit] at org.apache.commons.jelly.tags.xml.TestXMLTags.testTransformSchematron(TestXMLTags.java:231) [junit] Root cause [junit] java.lang.NoSuchMethodError [junit] at org.apache.commons.jelly.tags.xml.TransformTag$1.resolve(TransformTag.java:221) [junit] at org.apache.xalan.processor.ProcessorInclude.parse(ProcessorInclude.java:235) [junit] at org.apache.xalan.processor.ProcessorInclude.startElement(ProcessorInclude.java:192) [junit] at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:658) [junit] at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) [junit] at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) [junit] at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source) [junit] at org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(Unknown Source) [junit] at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source) [junit] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) [junit] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) [junit] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) [junit] at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) [junit] at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) [junit] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [junit] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) [junit] at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:983) [junit] at org.apache.xalan.processor.TransformerFactoryImpl.newTransformerHandler(TransformerFactoryImpl.java:700) [junit] at org.apache.commons.jelly.tags.xml.TransformTag.doTag(TransformTag.java:124) [junit] at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262) [junit] at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) [junit] at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186) [junit] at org.apache.commons.jelly.tags.core.JellyTag.doTag(JellyTag.java:45) [junit] at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262) [junit] at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:706) [junit] at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:670) [junit] at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:579) [junit] at org.apache.commons.jelly.tags.xml.TestXMLTags.evaluteScriptAsText(TestXMLTags.java:309) [junit] at
[jira] Created: (JELLY-217) org.apache.commons.jelly.tags.xml.ElementTag small bug in output wrapper
org.apache.commons.jelly.tags.xml.ElementTag small bug in output wrapper Key: JELLY-217 URL: http://issues.apache.org/jira/browse/JELLY-217 Project: jelly Type: Bug Components: taglib.xml Reporter: Diogo Bacelar Quintela Priority: Trivial ElementTag has some small problems XMLOutput newOutput = new XMLOutput(output) { ... } Should include public void startPrefixMapping(String prefix, String uri) throws SAXException { initialize(); super. startPrefixMapping (prefix, uri); } startPrefixMapping is called automatically in startElement, so whenever a child script wants to start outputing, it will call startPrefixMapping before startElement (if needed). To attain correctness, we should override startPrefixMapping as it's done in startElement. Related, we could do the same for public void comment(char ch[], int start, int length) throws SAXException { initialize(); super. comment (ch, start, length); } to support x:element name=abc x:commentmy comment/x:comment /x:element to generate abc !-- my comment -- /abc -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Updated: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=all ] Diogo Bacelar Quintela updated JELLY-213: - Attachment: jelly-patch4.patch Fixed an error when generating the following sample. env:Envelope xmlns:env=http://schemas.xmlsoap.org/soap/envelope/; env:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; env:encodingStyle was comming with uri=, localName and qName=env:encodingStyle Fixed junit tests: included xmlunit in junit testing in xml tag library. Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-patch3.patch, jelly-patch4.patch, jelly-xml-updated.patch, jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=comments#action_12315396 ] Diogo Bacelar Quintela commented on JELLY-213: -- I also believe that the solution should be maintaining a stack of declared namespaces as SAXContentHandler does, managed in XMLOutput, in startPrefixMapping/endPrefixMapping and startElement (maybe endElement also..). If this aproach is taken, we could be using only patch 1 (discarding patch 2)... Forcing generation of a prefix seems very ugly.. Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-xml-updated.patch, jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=comments#action_12315405 ] Diogo Bacelar Quintela commented on JELLY-213: -- org.apache.commons.jelly.NamespaceAwareTag interface helps in knowing the current namespaces... for example: ?xml version=1.0 encoding=UTF-8? j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml xmlns=abc top-node x:element name=test-node x:attribute URI=http://apache/testNS; name=test:abc trim=truetestValue/x:attribute !-- attributes without ':' should not have namespace -- x:attribute URI=http://apache/testNS; name=abc2 trim=truetestValue/x:attribute x:attribute name=abc3 trim=truetestValue/x:attribute /x:element /top-node /j:jelly and the following code in doTag of ElementTag -- Set entries = prefixToUriMap.entrySet(); System.out.println(localName=+localName+,name=+name+-); for (Iterator iter = entries.iterator(); iter.hasNext();) { Map.Entry entry = (Entry) iter.next(); System.out.println(ElementTag.doTag() prefix=+entry.getKey() + , value=+entry.getValue()); } System.out.println(); -- results in... localName=test-node,name=test-node- ElementTag.doTag() prefix=x, value=jelly:xml ElementTag.doTag() prefix=j, value=jelly:core ElementTag.doTag() prefix=, value=abc However...(running with patch2, and a non dom4j xmloutput) [ie, in TestXMLTags testcase] ends with top-node test-node xmlns:test=http://apache/testNS; test:abc=testValue abc2=testValue abc3=testValue /test-node /top-node :( top-node doesn't come with 'xmlns=abc' We really need to set a namespace stack in xmloutput i guess.. :( Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-xml-updated.patch, jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=comments#action_12315419 ] Diogo Bacelar Quintela commented on JELLY-213: -- I am already working on it. It would behave has using a saxcontenthandler :) i mean transparently. Higher correctness, less complex for tags. Even Element tag would not need to implement org.apache.commons.jelly.NamespaceAwareTag. Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-xml-updated.patch, jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Updated: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=all ] Diogo Bacelar Quintela updated JELLY-213: - Attachment: jelly-patch3.patch Here is patch3 :) AtributeTag and ElementTag are exactly the same as patch 1 XMLOutput now has a stack of namespaces, and manages the calls to startPrefixMapping and endPrefixMapping. It passes common testcases and jelly-xml testcases (haven't tried the others :) It now generates equivalent outputs in both cases (described in above java class TestNS) [equivalent means equivalent xml, not necessarly the same order of attributes]. I've included a new tag, that i mentionated some comments above. A ReplaceNamespaceTag. As it name implies, it replaces all namespaces from one uri to another in its body (fromURI and toURI properties). XMLOutput does it job perfectly, again :) Ex: ?xml version=1.0 encoding=UTF-8? j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${ns} name=test-node x:attribute URI=http://apache/testNS; name=test:abc trim=truetestValue/x:attribute test-subnode attr=test test-anotherSubNode / x:element URI=${ns} name=test-anotherSubNodeAgain x:attribute URI=${ns} name=other:abc trim=truetestValue/x:attribute /x:element /test-subnode x:replaceNamespace toURI=${ns} test-subnode attr=test test-anotherSubNode / x:element URI=${ns} name=test-anotherSubNodeAgain x:attribute URI=${ns} name=other:abc trim=truetestValue/x:attribute /x:element /test-subnode /x:replaceNamespace /x:element /j:jelly Generates When 'ns' is empty/inexistent test-node xmlns:test=http://apache/testNS; test:abc=testValue test-subnode attr=test test-anotherSubNode /test-anotherSubNode test-anotherSubNodeAgain xmlns:other= other:abc=testValue /test-anotherSubNodeAgain /test-subnode /test-node And when 'ns' if for example 'http://java/ns' test-node xmlns:test=http://apache/testNS; xmlns=http://java/ns; test:abc=testValue test-subnode xmlns= attr=test test-anotherSubNode /test-anotherSubNode test-anotherSubNodeAgain xmlns:other=http://java/ns; xmlns=http://java/ns; other:abc=testValue /test-anotherSubNodeAgain /test-subnode test-subnode attr=test test-anotherSubNode /test-anotherSubNode test-anotherSubNodeAgain xmlns:other=http://java/ns; other:abc=testValue /test-anotherSubNodeAgain /test-subnode /test-node Usefull ? I'll demonstrate with my example. I am working in ejb plugin for xdoclet-plugins project, the plugins for xdoclet2 project. plugin.version.isDtd says true if we need an dtd, false, if we are using a schema. If we are using a dtd, we don't need a namespace, if we are using a schema we need to use 'http://java.sun.com/xml/ns/j2ee' as default namespace. So plugin.version.ns return null when is a dtd, and 'http://java.sun.com/xml/ns/j2ee' when its not. With this 'replaceNamespace' tag we can use the default namespace in jelly script, (replacing for let's it exactly the same :D) for dtd output, and when plugin.version.ns is http://java.sun.com/xml/ns/j2ee all nodes get automatically updated to that namespace. It will be usefull for xdoclet-plugins, and maybe for other projects. ?xml version=1.0 encoding=UTF-8? j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml xmlns:jsl=jelly:jsl j:if test=${plugin.version.isDtd()} x:doctype name=ejb-jar publicId=${plugin.version.publicId} systemId=${plugin.version.systemId} trim=true / /j:if x:element URI=${plugin.version.ns} name=ejb-jar j:if test=${!plugin.version.isDtd()} x:attribute URI=${plugin.version.xsiNs} name=xsi:schemaLocation trim=true${plugin.version.schemaLocation}/x:attribute x:attribute name=version trim=true${plugin.version.version}/x:attribute /j:if x:replaceNamespace toURI=${plugin.version.ns} includeAttributes=true enterprise-beans j:forEach var=class items=${metadata} j:if test=${plugin.shouldGenerate(class)} entity ejb-name${plugin.ejbUtils.getEjbName(class)}/ejb-name /entity /j:if /j:forEach /enterprise-beans /x:replaceNamespace j:import uri=org/xdoclet/plugin/ejb/descriptor/entity-beans.jelly inherit=true/ /x:element !--/ejb-jar -- /j:jelly If this patch is usefull as a full (as i think it is), i'd be happy to known when it gets added to jelly project, and jelly-xml. Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug
[jira] Commented: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=comments#action_12315291 ] Diogo Bacelar Quintela commented on JELLY-213: -- Jelly Script (TestNs.jelly) ?xml version=1.0 encoding=UTF-8? j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml one x:element URI=http://apache/testNS; name=two x:attribute URI=http://apache/anotherNS; name=test:abc2 trim=true testValue /x:attribute threehi/three /x:element /one /j:jelly ## NOTES: Element one has no default namespace because j:jelly does not define one, so nor does element three. Element two should be declared to be in namespace http://apache/testNS; The namespace URI set for ElementTag don't get reset if using a no dom4j-XMLOutput, and exists before patch 1 (http://issues.apache.org/jira/browse/JELLY-213, jelly-xml.patch) because ElementTag already allows to set a namespace. See bellow SAMPLE OUTPUTS Java Test # (TestNs.java) import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.net.URL; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.XMLOutput; import org.apache.xml.serialize.Method; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.dom4j.io.SAXContentHandler; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import org.xml.sax.SAXException; public class TestNs { public TestNs() { } public void serializeUsingSimpleXMLOutput( String fileName, Writer writer) throws JellyException, IOException { JellyContext context = new JellyContext(); // cature the output // XMLOutput output = XMLOutput.createXMLOutput(writer); org.dom4j.io.OutputFormat outputFormat = new org.dom4j.io.OutputFormat(); outputFormat.setSuppressDeclaration(true); outputFormat.setNewlines(true); outputFormat.setIndent(true); outputFormat.setIndentSize(4); XMLWriter xmlWriter = new XMLWriter(writer, outputFormat); XMLOutput output = new XMLOutput(xmlWriter); URL fUrl = getClass().getResource(fileName); context.runScript( fUrl, output ); //xmlWriter.close(); output.flush(); writer.write('\n'); writer.flush(); } public void serializeUsingSAXContentHandler( String fileName, Writer writer) throws IOException, JellyException, SAXException { org.dom4j.io.OutputFormat outputFormat = new org.dom4j.io.OutputFormat(); outputFormat.setSuppressDeclaration(true); outputFormat.setNewlines(true); outputFormat.setIndent(true); outputFormat.setIndentSize(4); XMLWriter xmlWriter = new XMLWriter(writer, outputFormat); xmlWriter.setEscapeText(false); SAXContentHandler saxHandler = new SAXContentHandler(); XMLOutput output = new XMLOutput(saxHandler); // now run a script using a URL JellyContext context = new JellyContext(); URL fUrl = getClass().getResource(fileName); output.startDocument(); context.runScript(fUrl, output); output.endDocument(); xmlWriter.write(saxHandler.getDocument()); xmlWriter.flush(); } public static void main(String[] args) { try { TestNs t = new TestNs(); Writer someWriter = new OutputStreamWriter(System.out); System.out.println(--); t.serializeUsingSAXContentHandler(TestNs.jelly, someWriter); System.out.println(--); t.serializeUsingSimpleXMLOutput(TestNs.jelly, someWriter); System.out.println(--); } catch (Exception e) { e.printStackTrace(); } } } # NOTES: serializeUsingSAXContentHandler uses dom4j facilities serializeUsingSimpleXMLOutput does not SAMPLE OUTPUTS ## With PATCH 1 (http://issues.apache.org/jira/browse/JELLY-213, jelly-xml.patch). As Paul said, imcomplete because of lack of use of startPrefixMapping/endPrefixMapping ### OUTPUT ### -- one two xmlns=http://apache/testNS; xmlns:test=http://apache/anotherNS; test:abc2=testValue three xmlns=hi/three /two /one -- one two test:abc2=testValue threehi/three /two /one -- ## With PATCH 2 (http://issues.apache.org/jira/browse/JELLY-213, jelly-xml-updated.patch). startPrefixMapping/endPrefixMapping as possible, presenting better results. Problem. XMLOutput doesn't have state,
[jira] Commented: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=comments#action_12315221 ] Diogo Bacelar Quintela commented on JELLY-213: -- I'll investigate what you said. Btw, I am adding a tag to jelly-xml tags that i'll add as a patch later... A tag to suppport namespace subtitution, i'll explain it's needs then.. Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Updated: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=all ] Diogo Bacelar Quintela updated JELLY-213: - Attachment: jelly-xml-updated.patch Patch superseeds already uploaded patch. Fixed namespace processing using startPrefixMapping and endPrefixMapping as Paul Libbrecht sugested. TestCase included. Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-xml-updated.patch, jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Created: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=comments#action_12315134 ] Diogo Bacelar Quintela commented on JELLY-213: -- I guess this is related to http://issues.apache.org/jira/browse/JELLY-173 Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Updated: (JELLY-213) Generating xml nodes with attributes in diferente namespaces (for schemas..)
[ http://issues.apache.org/jira/browse/JELLY-213?page=all ] Diogo Bacelar Quintela updated JELLY-213: - Attachment: jelly-xml.patch ?xml version=1.0 encoding=UTF-8? j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml xmlns:jsl=jelly:jsl x:element URI=http://java.sun.com/xml/ns/j2ee; name=ejb-jar x:attribute URI=http://www.w3.org/2001/XMLSchema-instance; name=xsi:schemaLocation trim=true http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd /x:attribute x:attribute name=version trim=true 1.2 /x:attribute /x:element /j:jelly Works as expected generating ejb-jar xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd; version=1.2 /ejb-jar Generating xml nodes with attributes in diferente namespaces (for schemas..) Key: JELLY-213 URL: http://issues.apache.org/jira/browse/JELLY-213 Project: jelly Type: Bug Reporter: Diogo Bacelar Quintela Attachments: jelly-xml.patch I tried to find some info googling around and in the faq and couldn't find the answer, so here it goes. I need to generate the following xml (it's a sample off course), to support schemas. NodeName xmlns=http://blah/bleh; xmlns:xsi=http://www.w3.org/2001/XMLSchema; xsi:schemaLocation=http://blah/blehSchemaLocation; !-- Other content here -- /NodeName After several tries and some inconsistent behaviour, I thought the following jelly excerpt should be close to the solution, however xml:attribute doesn't support namespaces values. j:jelly xmlns:j=jelly:core xmlns:x=jelly:xml x:element URI=${myns} name=NodeName x:attribute name=xsi:schemaLocation URI=${myxsins} trim=true ${myschemaloc} /x:attribute !-- Other content here -- x:element /j:jelly Where myns is for example http://blah/bleh myschemaloc is for example http://blah/blehSchemaLocation myxsins is for example http://www.w3.org/2001/XMLSchema Is there any known solution for this problem? Even if working only for schemas? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]