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

Thomas Scheffler thomas.scheffler at uni-jena.de
Tue Aug 9 23:32:40 PDT 2011


Hi,

sorry I am missing a mail from a list or something. I do not have the 
full code here for a proper review. But from the mail It seems as you 
are using tree traversal to get the correct namespace prefix. This looks 
a bit silly to me, as this can be a lot of work on large XML-files 
although it should work, too.

Why do you not use my second patch with the startPrefixMapping() and 
endPrefixMapping()? For me it looks better to store this information in 
a proper place and throw it away after endPrefixMapping() event, than 
walking up the tree.

But again, I am missing the code you both are talking about.

regards,

Thomas

Am 10.08.2011 01:14, schrieb Jason Hunter:
> // First look at the element itself
>
>> if (p.getNamespace().getURI().equals(attURI)
>> && !overrides.contains(p.getNamespacePrefix())
>> && !"".equals(element.getNamespace().getPrefix())) {
>> // we need a prefix. It's impossible to have a namespaced
>> // attribute if there is no prefix for that attribute.
>> attNS = p.getNamespace();
>> break uploop;
>> }
>
> // Then any additional namespaces defined on the element
>
>> overrides.add(p.getNamespacePrefix());
>> for (Iterator it = p.getAdditionalNamespaces().iterator();
>> it.hasNext(); ) {
>> Namespace ns = (Namespace)it.next();
>> if (!overrides.contains(ns.getPrefix())
>> && attURI.equals(ns.getURI())) {
>> attNS = ns;
>> break uploop;
>> }
>> overrides.add(ns.getPrefix());
>> }
>
> // If we haven't hit something yet, keep walking up the tree
>
>> if (p == element) {
>> p = currentElement;
>> } else {
>> p = p.getParentElement();
>> }
>> } while (p != null);


More information about the jdom-interest mailing list