You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Tony Robertson (JIRA)" <co...@jakarta.apache.org> on 2005/08/22 07:53:27 UTC
[jira] Commented: (JELLY-184) Using namespace-prefixes breaks Jelly
[ http://issues.apache.org/jira/browse/JELLY-184?page=comments#action_12319540 ]
Tony Robertson commented on JELLY-184:
--------------------------------------
Here is an example jelly script that still doesn't work because of this bug:
<?xml version="1.0" ?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">
<j:parse>
<x:transform xslt="code2jelly.xsl">
<x:transform xml="operations.xml" xslt="ops2code.xsl" />
</x:transform>
</j:parse>
</j:jelly>
The "code2jelly.xsl" transform produces a jelly script which I want to run.
If I save the transform output to a file, then run it as a jelly script, it works OK.
However, when the script body is coming directly from the SAX event stream of the transform, the namespace definitions (eg xmlns:x="jelly:xml") show up as attributes that the script compiler chokes on, exactly as described above.
It looks like the following code is responsible:
In the "org.apache.commons.jelly.parser.XMLParser" class, the "createTag" method, where it loops through each attribute and does a "script.addAttribute(attributeName, expression);"
I think this code should check the namespace of the attributes (where available), and only add the attributes having the same namespace as the tag.
- Tony
> Using namespace-prefixes breaks Jelly
> -------------------------------------
>
> Key: JELLY-184
> URL: http://issues.apache.org/jira/browse/JELLY-184
> Project: jelly
> Type: Bug
> Components: core / taglib.core
> Reporter: dion gillard
>
> Using feature "http://xml.org/sax/features/namespace-prefixes" breaks Jelly.
> SAXParserFactory pf = SAXParserFactory.newInstance();
> pf.setValidating (false);
> pf.setNamespaceAware (true);
> pf.setFeature ("http://xml.org/sax/features/namespace-prefixes", true);
> XMLReader reader = null;
> SAXParser parser = pf.newSAXParser();
> reader = parser.getXMLReader();
> InputSource inSrc = new InputSource
> (new FileReader(new File ("util/test.jelly")));
> Jelly jelly = new Jelly();
> JellyContext context = new JellyContext ();
> ExtXMLParser jellyParser = new ExtXMLParser ();
> jellyParser.setContext(context);
> jellyParser.configure ();
> reader.setContentHandler(jellyParser);
> reader.parse (inSrc);
> Script script = jellyParser.getScript ();
> script.compile ();
> script.run (context, XMLOutput.createXMLOutput(System.out));
> results in:
> [junit] org.apache.commons.jelly.JellyTagException: null:-1:-1: <null>
> null:2:88: <j:jelly> This tag does not understand the '' attribute
> [junit] at
> org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:600)
> [junit] at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:239)
> [junit] at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:89)
> The offending line is "pf.setFeature
> ("http://xml.org/sax/features/namespace-prefixes", true)"
> While setting this feature is, of course, not necessary for Jelly, the Jelly
> script I want to use in the real application is embedded within a larger XML
> file. This file is parsed into a SAX event buffer with the feature set (because
> in general, namespace-prefixes are needed). The SAX events belonging to the
> Jelly script are then "extracted" and fed to Jelly. Of course, I can filter out
> the namespace prefix attributes (and I will, as a workaround). But Jelly should,
> of course, not break because of these attributes being reported.
> - Michael
--
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org