Re: jdom-interest Digest, Vol 56, Issue 13

View: New views
2 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: jdom-interest Digest, Vol 56, Issue 13

by S. Seide :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> But http://xml.org/sax/features/namespace-prefixes is set to true in
> SAXBuilder (along with http://xml.org/sax/features/namespaces), so my
> understanding is getQName() should never be "".  If its a unprefixed
> name, then getQName() should be returning the same as getLocalName().
> In this case "version".
>
> I can't remember, can you turn either of those SAX features off in SAXBuilder?

turning them off givs the following results (application specific part
of stack removed for better readability):

SAXBuilder parser = new SAXBuilder();
parser.setFeature("http://xml.org/sax/features/namespace-prefix", false);
Document doc = parser.build(is);

atts.getLocalName(i) - "version"
atts.getQName(i) - ""

> 07-30 13:04:49.965: ERROR/Global(844): java.lang.StringIndexOutOfBoundsException
> 07-30 13:04:49.965: ERROR/Global(844):     at java.lang.String.substring(String.java:1571)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.jdom.input.SAXHandler.startElement(SAXHandler.java:568)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:145)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.apache.harmony.xml.ExpatParser.append(Native Method)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:506)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
> 07-30 13:04:49.965: ERROR/Global(844):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:865)
...
> 07-30 13:04:49.965: ERROR/Global(844):     at dalvik.system.NativeStart.main(Native Method)

===

SAXBuilder parser = new SAXBuilder();
parser.setFeature("http://xml.org/sax/features/namespaces", false);
Document doc = parser.build(is);

> 07-30 13:09:58.367: ERROR/Global(898): org.jdom.input.JDOMParseException: Error in building: The 'namespace-prefix' feature is not supported while the 'namespaces' feature is enabled.: The 'namespace-prefix' feature is not supported while the 'namespaces' feature is enabled.
> 07-30 13:09:58.367: ERROR/Global(898):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:538)
> 07-30 13:09:58.367: ERROR/Global(898):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:865)
...
> 07-30 13:09:58.367: ERROR/Global(898):     at dalvik.system.NativeStart.main(Native Method)
> 07-30 13:09:58.367: ERROR/Global(898): Caused by: org.xml.sax.SAXNotSupportedException: The 'namespace-prefix' feature is not supported while the 'namespaces' feature is enabled.
> 07-30 13:09:58.367: ERROR/Global(898):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:264)
> 07-30 13:09:58.367: ERROR/Global(898):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
> 07-30 13:09:58.367: ERROR/Global(898):     ... 18 more
> 07-30 13:09:58.367: ERROR/Global(898): Caused by: org.xml.sax.SAXNotSupportedException: The 'namespace-prefix' feature is not supported while the 'namespaces' feature is enabled.
> 07-30 13:09:58.367: ERROR/Global(898):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:264)
> 07-30 13:09:58.367: ERROR/Global(898):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
> 07-30 13:09:58.367: ERROR/Global(898):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:865)
...
> 07-30 13:09:58.367: ERROR/Global(898):     at dalvik.system.NativeStart.main(Native Method)

===

SAXBuilder parser = new SAXBuilder();
parser.setFeature("http://xml.org/sax/features/namespaces", false);
parser.setFeature("http://xml.org/sax/features/namespace-prefix", false);
Document doc = parser.build(is);

> 07-30 13:13:21.586: ERROR/Global(935): org.jdom.JDOMException: http://xml.org/sax/features/namespace-prefix feature not recognized for SAX driver org.apache.harmony.xml.ExpatReader
> 07-30 13:13:21.586: ERROR/Global(935):     at org.jdom.input.SAXBuilder.internalSetFeature(SAXBuilder.java:827)
> 07-30 13:13:21.586: ERROR/Global(935):     at org.jdom.input.SAXBuilder.setFeaturesAndProperties(SAXBuilder.java:766)
> 07-30 13:13:21.586: ERROR/Global(935):     at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:621)
> 07-30 13:13:21.586: ERROR/Global(935):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:489)
> 07-30 13:13:21.586: ERROR/Global(935):     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:865)
...
> 07-30 13:13:21.586: ERROR/Global(935):     at dalvik.system.NativeStart.main(Native Method)


regards,
S. Seide
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: Re: jdom-interest Digest, Vol 56, Issue 13

by Bradley S. Huffman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 30, 2009 at 8:17 AM, S. Seide<ml-jdom@...> wrote:

>> But http://xml.org/sax/features/namespace-prefixes is set to true in
>> SAXBuilder (along with http://xml.org/sax/features/namespaces), so my
>> understanding is getQName() should never be "".  If its a unprefixed
>> name, then getQName() should be returning the same as getLocalName().
>> In this case "version".
>>
>> I can't remember, can you turn either of those SAX features off in SAXBuilder?
>
> turning them off givs the following results (application specific part
> of stack removed for better readability):

Oops sorry, what I meant was I'm confused why getQName is returning an
empty string.

If you're turning either SAX feature off that may explain why getQName
is returning an empty string.  The SAXBuilder.setProperty javadocs are
vague, but those two features are the ones that are currently required
to be set to true, and are done so by default in SAXBuilder.  Setting
either of them to false may or may not cause an exception.  It would
depend on the parser.

However, if you are not setting any SAX features and using the
defaults, then getQName should never be the empty string.  If it is
that suggests a bug in the parser.

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...