Hi Mark,
I agree that the implementation does not cope with all of the complexities of 
possible naming patterns that may be employed, but I would be interested to 
understand how you expect to maintain the list of namespaces.

I regularly handle files of 10M to 100Mb, and modify these documents based on 
XPath based rules.

Scanning the document in this case is not an option, and as namespaces may be 
removed, and content shared within the document, maintaining a map of usage is 
not trivial in code, CPU or memory.

I would suggest that any code that determines namespace could use a namespace 
resolution strategy that is appropriate for its needs, and this should be able 
to be defaulted without code.
This is what the DefaultNamespaceContext does, albeit without strategy options, 
but any progreammer can withthe 1.6.1 implementation provide a different 
namespace context, appropriate for their needs, and what you are proposing is 
such an alternative I believe


The code for retrieval  is in 1.6.1
see AbstractElement.getNamespaceForPrefix, and 
DefaultElement.getNamespaceForPrefix

Also NamespaceStack.

The mechanism for retrieveal is I believe linked in with the Jaxen namespace 
resolution techniques, as can be seen by an inspection of 
DefaultNamespaceContext.

Regards
Mike Skells
Chief Solutions Architect
ValidSoft Ltd
F: +44 (0) 20 7033 1965
M: +44 (0) 7740 520 717
[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>
<http://www.validsoft.com/>www.validsoft.com<http://www.validsoft.com/>
ValidSoft Ltd is a Private Limited Company.
Registered Address:Castle Buildings, Tara Street, Tullamore, Co. Offaly, 
Ireland.
Registration Number: 377068 Registered in Dublin.
The information in this e-mail is confidential and may be legally privileged. 
It is intended solely for the addressee(s).  Access to this e-mail by anyone 
else is unauthorised. If you are not the intended recipient, any disclosure, 
copying, distribution or any action taken or omitted to be taken in reliance on 
it, is prohibited and may be unlawful. When addressed to our clients any 
opinions or advice contained in this e-mail are subject to the terms and 
conditions expressed in the governing ValidSoft client terms and conditions.



________________________________
From: Marc Pellmann [mailto:[EMAIL PROTECTED]
Sent: 06 November 2008 08:44
To: Mike Skells
Cc: [EMAIL PROTECTED]; dom4j-dev@lists.sourceforge.net
Subject: Re: [dom4j-dev] dom4j extensions

Hi!

In older version (1.6 etc) a namespace context was created by walking the 
element hierarchy and picking the namespaces that were defined in the element 
that is the context of the xpath statement

I do not see this in 1.6.1 but I think it would not be enough if it is there. 
The xpath expression could be of any complexity and could try to select nodes 
in all other branches of the document and in deeper of the actual with own 
namespace declarations, too. And this branches have other namespace 
declarations and maybe the prefixes would be the same with other URIs or there 
are default namespaces without prefixes, that need to be changed (added with 
prefix).

There is no method to get all namespaces that are defined in the document. So 
this is what I have added. In many cases it would be enough to add namespaces 
unchanged to the xpath expression. But in the situations above it is needed to 
change prefixes of some namespace definitions that should be added to the 
context and this is done, too. The xpath need to use this new prefixes - there 
is no code in the moment to automatically change some pathes, because this 
might be extreme complex. Again the xpath could be of any complexity.

As an example try come xpathes with this xml:

<OOO xmlns="http://zvon.org/xnumber";<http://zvon.org/xnumber> 
xmlns:lower="http://zvon.org/lowercase";<http://zvon.org/lowercase> ooo="222">
  <aaa>
    <lower:BBB 
xmlns:lower="http://zvon.org/uppercase";<http://zvon.org/uppercase>>
      <lower:x111/>
      <sss xmlns:lower="http://zvon.org/xnumber";<http://zvon.org/xnumber>>
        <lower:x111/>
      </sss>
    </lower:BBB>
    <lower:x111/>
  </aaa>
  <aaa xmlns="http://zvon.org/uppercase";<http://zvon.org/uppercase>>
    <BBB xmlns:upper="http://zvon.org/uppercase";<http://zvon.org/uppercase> 
upper:U="A" U="A" lower:U="A"></BBB>
  </aaa>
  <aaa xmlns="http://zvon.org/lowercase";<http://zvon.org/lowercase>>
    <upper:BBB 
xmlns:upper="http://zvon.org/uppercase";<http://zvon.org/uppercase> 
xmlns="http://zvon.org/xnumber";<http://zvon.org/xnumber>>
      <x111/>
    </upper:BBB>
    <x111/>
  </aaa>
</OOO>

--
Viele Grüße / best regards

Marc Pellmann (Software Architect)

inubit - integrating your business and IT
inubit AG
Schöneberger Ufer 89-91
D-10785 Berlin
Fon: +49.30. 72 61 12-132
Fax: +49.30. 72 61 12-100
Freecall: 0800-go inubit
Web: www.inubit.com<http://www.inubit.com>

Vorstand: Dr. Torsten Schmale
Vorsitzender des Aufsichtsrates: Dr. Wolf-Dieter Klemt
Registergericht: AG Charlottenburg
Registernummer: HRB 80154
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to