[erlang-questions] xmerl_xpath and namespaces

denis dloutrein.lists@REDACTED
Fri Oct 3 23:40:43 CEST 2008


Hello,

 

I'm having some problem using xmerl_xpath on a document having namespaces.
I'm not sure I fully understand how all of this work and the problem should
not come from xmerl_xpath, but from my misunderstanding of xml, namespace,
xpath.

It seems that with xpath, it's mandatory to give the namespace.

 

For instance, in a document like this:

 

<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"


 
targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">

  <xs:simpleType name="char">

      <xs:restriction base="xs:int"/>

  </xs:simpleType>

  <xs:element name="duration" nillable="true" type="tns:duration"/>

  <xs:simpleType name="duration">

      <xs:restriction base="xs:duration">

          <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>

              <xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>

              <xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>

      </xs:restriction>

  </xs:simpleType>

  <xs:element name="guid" nillable="true" type="tns:guid"/>

</xs:schema>

 

If I want to get all "element" attributes, I need to do a query like 

xmerl_xpath:string("//xs:simpleType", X)

Is there a way to not having to give the namespace in the query ??

Another related question is the usage of {namespace, .} option in the query.
What is it's usage ? A tried something like this

xmerl_xpath:string("//simpleType", X, [{namespace,
X#xmlElement.namespace}]).

Hoping for a miracle. Of course, no miracle :-)

I don't understand what do this option.

 

My problem is that I get different schema "element"s, which are in two
different namespaces. I can't see how to retrieve them using xpath.

One namespace is declared in the root element, so I can get it's definition
and add the namespace manually when building the query, but in the case
above, the namespace is defined in the schema node itself, so I can't get
it.

 

If anybody can give me some highlight or pointers, this would help me a lot
! :-)

 

Thanks

Denis

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081003/590b895c/attachment.htm>


More information about the erlang-questions mailing list