[jdom-interest] Parsing a MODS-document with validation fails

Thomas Scheffler thomas.scheffler at uni-jena.de
Mon Jul 25 00:05:00 PDT 2011

Am 24.07.2011 23:46, schrieb Bradley S. Huffman:
> And if the prefix "ns1" is already mapped to another URI because the
> user decided to use "ns1" as a prefix, what kind of havoc will this
> cause?

I got your point! We have to check if "ns"+nsPrefixCount is already 
defined, if we create it. I do not know though if that is enough. We can 
do this for the current element and be sure of that. But if  for 
instance we have three tag: "a","b","c", where "a" is parent of "b" an 
that is parent of "c". There could be an issue if "a" defines a 
namespace with prefix "ns?" that is in use by "c" and not by "b".
When it comes to "b" we see the namespace prefix is currently undefined. 
And bound it to the new uri. This way the namespace in c changes.
So we have to drag every usage of a prefix throughout the document with 
the "endPrefixMapping" event, that is currently missing an 
implementation in SAXHandler.
Do you agree?



> On Fri, Jul 22, 2011 at 4:08 PM, Thomas Scheffler
> <thomas.scheffler at uni-jena.de>  wrote:
>> Am 22.07.2011 22:53, schrieb Bradley S. Huffman:
>>> I'm not sure about a patch that makes up a namespace prefix.  From the
>>> patch
>>>            nsPrefixCount++;
>>>            ns = Namespace.getNamespace("ns" + nsPrefixCount, attUri);
>>> Seems like a kludge.  My gut says it's something else.
>> This is how it is done by the Oracle JAVA DocumentBuilder. JDOM won't accept
>> a namespace without a prefix so you have to build some as the SAXParser
>> delivers an attribute with QName=LocalName. Before that I take a look in
>> predeclared namespaces, so that any prefix that is bound to an URI is used
>> before building a new one. For the testing case I submitted in my original
>> mail, "xlink" is found correctly which makes it more beautiful than the
>> DocumentBuilder solution that creates "ns0" on every element with xlink:type
>> set fixed to "simple". Hope you can follow my arguments.
>> regards,
>> Thomas

More information about the jdom-interest mailing list