commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Libbrecht <p...@activemath.org>
Subject Re: Jelly Question/Issue - XML with namespace in template??
Date Tue, 21 Jul 2009 04:13:22 GMT
Jason,

I still don't understand your point.
If you want this kind of "arbitrary text generation" than you cannot  
avoid leaving the cute world of SAX pipelines which is where jelly  
lives.
You can easily use the disablement of output escaping if you wish but  
this can only happen at the final stage.

paul


Le 17-juil.-09 à 04:06, Jason Weinstein a écrit :

>
> Thank you for your response.
>
> I will start with the second example to make my concerns more clear.
>
> I would like to generate this output:
>
> output:
>    <hello:bye> hi </hello:bye>
>
>
> I had hoped something like this would work:
>
> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml">
>    <hello:bye> hi </hello:bye>
> </j:jelly>
>
> However it gives the error below:
>
> org.xml.sax.SAXParseException: The prefix "hello" for element  
> "hello:bye" is not bound.
>
>
> My concern is that for a general templating mechanism which is my  
> use case i must be able to generate any text and easily. In this  
> case the xml generated is not well formed, but i would still like to  
> be able to generate it.
>
> This template actually produces the right code
>
> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml">
>    &lt;hello:bye&gt; hi &lt;/hello:bye&gt;
> </j:jelly>
>
> But assume the xml to be generated is quite complex then this type  
> of xml escaped template becomes very complex to manage.
>
> I would prefer if it just ignored the <hello:bye> tag and did not  
> try to parse it. Perhaps this is a drawback of this toolkit or  
> perhaps there is a way to work around it?
>
> Full error:
>
> Jul 17, 2009 12:51:48 AM org.apache.commons.jelly.parser.XMLParser  
> fatalError
> SEVERE: Parse Fatal Error at line 2 column 16: The prefix "hello"  
> for element "hello:bye" is not bound.
> org.xml.sax.SAXParseException: The prefix "hello" for element  
> "hello:bye" is not bound.
>    at  
> org 
> .apache 
> .xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown  
> Source)
>    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown  
> Source)
>    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown  
> Source)
>    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown  
> Source)
>    at  
> org 
> .apache 
> .xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
>    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl 
> $FragmentContentDispatcher.dispatch(Unknown Source)
>    at  
> org 
> .apache 
> .xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown  
> Source)
>    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    at Main.main(Main.java:25)
> org.apache.commons.jelly.JellyException: null:-1:-1: <null>  
> null:-1:-1: <null> Could not parse Jelly script
>    at SlotUtil.runScript(SlotUtil.java:46)
>    at Main.main(Main.java:25)
> Caused by: org.apache.commons.jelly.JellyException: null:-1:-1:  
> <null> Could not parse Jelly script
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 547)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    ... 1 more
> Caused by: org.xml.sax.SAXParseException: The prefix "hello" for  
> element "hello:bye" is not bound.
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    ... 5 more
> Root cause
> org.apache.commons.jelly.JellyException: null:-1:-1: <null> Could  
> not parse Jelly script
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 547)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    at Main.main(Main.java:25)
> Caused by: org.xml.sax.SAXParseException: The prefix "hello" for  
> element "hello:bye" is not bound.
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    ... 5 more
> Root cause
> org.xml.sax.SAXParseException: The prefix "hello" for element  
> "hello:bye" is not bound.
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    at Main.main(Main.java:25)
> org.apache.commons.jelly.JellyException: null:-1:-1: <null> Could  
> not parse Jelly script
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 547)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    at Main.main(Main.java:25)
> Caused by: org.xml.sax.SAXParseException: The prefix "hello" for  
> element "hello:bye" is not bound.
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    ... 5 more
> Root cause
> org.xml.sax.SAXParseException: The prefix "hello" for element  
> "hello:bye" is not bound.
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    at Main.main(Main.java:25)
> org.xml.sax.SAXParseException: The prefix "hello" for element  
> "hello:bye" is not bound.
>    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
> Source)
>    at org.apache.commons.jelly.parser.XMLParser.parse(XMLParser.java: 
> 254)
>    at  
> org 
> .apache.commons.jelly.JellyContext.compileScript(JellyContext.java: 
> 543)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:678)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
>    at  
> org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
>    at SlotUtil.runScript(SlotUtil.java:39)
>    at Main.main(Main.java:25)
> Root cause
> Root cause
>
>
>> From: paul@activemath.org
>> To: user@commons.apache.org
>> Subject: Re: Jelly Question/Issue - XML with namespace in template??
>> Date: Fri, 17 Jul 2009 00:18:38 -0400
>>
>> Jason,
>>
>>
>> Le 16-juil.-09 à 22:45, Jason Weinstein a écrit :
>>> How does Jelly handle xml in the template??
>>
>> as is
>>
>>> Is it a good option for content with a lot of xml namespaces not
>>> referencing taglibs.
>>
>> definitely.
>>
>>> What about if validation is turned off?
>>
>> jelly has forgotten schemas since long... it's quite hard to have
>> schemas with glues such as jelly.
>>
>> I don't understand the below snippet though, it seems to mix java and
>> jelly... the java code here would just be considered text.
>> The fact that <hello:bye> fails at parsing is a normal xmlns story:
>> the hello prefix needs to be associated with a URI.
>>
>>> <?xml version="1.0"?>
>>> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml">
>>> import org.apache.commons.jelly.JellyTagException;
>>> import org.apache.commons.jelly.TagSupport;
>>> import org.apache.commons.jelly.XMLOutput;
>>>
>>> public class ${className} extends TagSupport {
>>>   public void doTag(XMLOutput output) throws JellyTagException {
>>>       // <hello:bye> hi </hello:bye> // THIS BIT FAILS IN PARSING
>>>       getBody().run(context, output);
>>>   }
>>> }
>>> </j:jelly>
>>
>>
>>
>>> How would i output something simple like this?
>>> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml">
>>>    <hello:bye> hi </hello:bye>
>>> </j:jelly>
>>
>> Output with j:jelly? At least with x:element you can, maybe there's a
>> cleaner way.
>>
>>> output
>>>   <hello:bye> hi </hello:bye>
>>
>> sounds like it's right to me.
>>
>> paul
>
> _________________________________________________________________
> Windows Live™ SkyDrive™: Get 25 GB of free online storage.
> http://windowslive.com/online/skydrive? 
> ocid=TXT_TAGLM_WL_SD_25GB_062009


Mime
View raw message