Re: Parsing a MODS-document with validation fails

Thomas Scheffler <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Organization Friedrich-Schiller-Universität Jena
Message-ID <[email protected]>
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);
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.