Bugs item #965893, was opened at 2004-06-03 18:30
Message generated for change (Comment added) made by maartenc
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=965893&group_id=16035

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Thomas Diesler (tdiesler)
Assigned to: Maarten Coene (maartenc)
Summary: element defines multiple namespaces for same URI

Initial Comment:
      I tried to use XPath expressions, but dom4j returns 
prefix "" for uri "http://www.w3.org/2001/XMLSchema";,
      which seems correct but it hides prefix "xs" which 
would need to be used in the XPath expression.

      Perhaps element.getNamespaceURI(String) should 
return a List.

      Therefore, the XPath is not valid. I'm not sure 
whether it is legal to define multiple prefixes
      for the same URI, or overlaying the default 
namespace with a more defined one as it is done in this 
example.

      <schema
          
targetNamespace="http://marshalltestservice.org/types2
"
          xmlns:foo="http://marshalltestservice.org/types2";
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema";
          xmlns="http://www.w3.org/2001/XMLSchema";
          elementFormDefault="qualified">

          <xs:include schemaLocation 
= "IncludedDefs.xsd"/>
          ...

      </schema>


----------------------------------------------------------------------

>Comment By: Maarten Coene (maartenc)
Date: 2004-06-16 15:39

Message:
Logged In: YES 
user_id=178745

I've added a method to Element to retrieve a List of
Namespaces for a given URI. Could you check it out from CVS
and give it a try?

thanks
Maarten

----------------------------------------------------------------------

Comment By: Maarten Coene (maartenc)
Date: 2004-06-10 22:30

Message:
Logged In: YES 
user_id=178745

ok I see: you use that method to construct your XPath at
runtime. I've tested your sample document with some
predefined XPath expressions which already contained the
prefix and so I didn't need that method. 

You should indeed iterate over all the prefixes that belong
to some URI (which I think is allowed to have multiple
prefixes for the same URI). I'll add such a method as soon
as possible. If it's urgent: you could commit a patch to
speed things up, or you could lookup all prefixes yourself
(using the implementation of the
AbstractElement.getNamespaceForURI() method as inspiration.

Thanks
Maarten

----------------------------------------------------------------------

Comment By: Thomas Diesler (tdiesler)
Date: 2004-06-10 22:21

Message:
Logged In: YES 
user_id=423364

Given that I don't know the xml document in advance, but 
want to get a list of all <include> elements that belong to the 
namespace "http://www.w3.org/2001/XMLSchema";.

I first get the prefix 
for "http://www.w3.org/2001/XMLSchema"; from the root 
element. Then I build up my XPath expression with that prefix.

String xpath = "//" + prefix + ":include";

This does not work, when the prefix I get form the root 
element is empty.

Note, that the xml I posted also uses 
http://www.w3.org/2001/XMLSchema as default prefix.

Theoretiacally I schould get a list of prefixes for a given 
namespace, because multiple aliases to the same namespace 
are allowed, or are they not?

cheers
-thomas

----------------------------------------------------------------------

Comment By: Maarten Coene (maartenc)
Date: 2004-06-10 22:10

Message:
Logged In: YES 
user_id=178745

Thomas,

Could you give me an example that fails? I've tried to test
your problem, but all my XPath expressions were evaluated
correctly.

Maarten

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=965893&group_id=16035


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to