SV: SV: [jdom-interest] How do you do it in JDOM?

Chris B. chris at tech.com.au
Tue Feb 17 07:11:22 PST 2004


That doesn't seem to work for me. When I go....

attributes.addAttribute("http://www.w3.org/XML/1998/namespace", "xml", 
"xmlns:xml", null, "http://www.w3.org/XML/1998/namespace");

I get the error...

org.jdom.input.JDOMParseException: Error on line 2 of document: Illegal 
Namespace prefix: "xml".

Caused by: org.jdom.input.JDOMParseException: Error on line 2 of 
document : Illegal Namespace prefix: "xml".

    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:377)

    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)

    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:703)

    at 
xena.plugin.base.AbstractOpenCustom.showXena(AbstractOpenCustom.java:199)

    ... 25 more

Caused by: org.xml.sax.SAXParseException: Illegal Namespace prefix: "xml".

    at org.apache.crimson.parser.Parser2.error(Parser2.java:3317)

    at 
org.apache.crimson.parser.Parser2.processAttributeNS(Parser2.java:1735)

    at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1583)

    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)

    at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)

    at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)

    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)

    ... 28 more







Per Norrman wrote:

>I never said anything about startPrefixMapping ... the xml prefix is
>by definition bound to http://www.w3.org/XML/1998/namespace, so it does
>not need to be mapped.
>
>JDOM expects that the URI is reported in the call to 
>org.xml.sax.Attributes#getURI(index). I guess that this is where your
>exception
>occurrs. If you're using org.xml.sax.helpers.AttributesImpl it's a
>simple
>matter to include the namespace uri.
>
>/pmn
>
>
>  
>
>>-----Ursprungligt meddelande-----
>>Från: Chris B. [mailto:chris at tech.com.au] 
>>Skickat: den 17 februari 2004 15:17
>>Till: Per Norrman
>>Kopia: jdom-interest at jdom.org
>>Ämne: Re: SV: [jdom-interest] How do you do it in JDOM?
>>
>>
>>
>>Yes, but the javadoc for ContentHandler says.....
>>
>>There should never be start/endPrefixMapping events for the 
>>"xml" prefix, since it is predeclared and immutable.
>>
>>That makes me wonder if it is a JDOM bug, since xml is assumed 
>>"predeclared".
>>
>>Besides which, making a call to ContentHandler.startPrefixMapping for 
>>"xml" seems to be ineffective.
>>
>>
>>Per Norrman wrote:
>>
>>    
>>
>>>Hi,
>>>
>>>make sure that this attribute reports the correct namespace uri: 
>>>http://www.w3.org/XML/1998/namespace
>>>
>>>/pmn
>>>
>>>
>>> 
>>>
>>>      
>>>
>>>>-----Ursprungligt meddelande-----
>>>>Från: jdom-interest-admin at jdom.org
>>>>[mailto:jdom-interest-admin at jdom.org] För Chris B.
>>>>Skickat: den 17 februari 2004 13:58
>>>>Till: jdom-interest at jdom.org
>>>>Ämne: Re: [jdom-interest] How do you do it in JDOM?
>>>>
>>>>
>>>>Ok, so I override createParser() in SAXBuilder so that I can
>>>>use my own 
>>>>custom XMLReader.
>>>>
>>>>The trouble is, my XML reader creates XML elements that contain the
>>>>attribute xml:space="preserve".
>>>>
>>>>And I get the error....
>>>>
>>>>ER org.jdom.IllegalNameException: The name "xml" is not legal for
>>>>JDOM/XML Namespace prefixs: Namespace prefixes cannot begin 
>>>>with "xml" 
>>>>in any combination of case.
>>>>ER     at org.jdom.Namespace.getNamespace(Namespace.java:154)
>>>>ER     at 
>>>>        
>>>>
>>org.jdom.input.SAXHandler.startElement(SAXHandler.java:511)
>>    
>>
>>>>Should this be regarded as a bug in JDOM?
>>>>
>>>>
>>>>_______________________________________________
>>>>To control your jdom-interest membership:
>>>>http://lists.denveronline.net/mailman/options/jdom-interest/yo
>>>>   
>>>>
>>>>        
>>>>
>>>uraddr at yourhost.com
>>>
>>>_______________________________________________
>>>To control your jdom-interest membership: 
>>>http://lists.denveronline.net/mailman/options/jdom-interest/y
>>>      
>>>
>ouraddr at yo
>  
>
>>urhost.com
>> 
>>
>>    
>>
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>  
>



More information about the jdom-interest mailing list