Page 1 of 1

Xinclude and XPointer.. How to ? Please help me

Posted: Fri Nov 24, 2006 5:30 pm
by manuel.dorne
Hello,

I've made a xinclude call like that:

<xs:appinfo>
<Actions>
<xi:include href="testXI.xml" xpointer="A1"/>
</Actions>
</xs:appinfo>

and here is the file where i have my information:

<Noms>
<Nom Init="DF" xml:id="A1" ><LastName>Faveur</LastName><FirstName>David</FirstName></Nom>
<Nom Init="MD"><LastName>Dorne</LastName><FirstName>Manuel</FirstName></Nom>
<Nom Init="PR"><LastName>Rajaud</LastName><FirstName>Patrick</FirstName></Nom>
</Noms>

I don't know how to get the firstname of the element id="A1" via my xpointer ?

Could you help me ?

Thanks

Posted: Fri Nov 24, 2006 7:23 pm
by sorin_ristache
Hello,

oXygen offers XInclude support through Xerces which does not support the entire xpointer() scheme. However you can include only the FirstName subelement that you want using the element() scheme:

Code: Select all

<xi:include href="testXI.xml" xpointer="element(/1/1/2)" xmlns:xi="http://www.w3.org/2001/XInclude"/>
Also oXygen adds support for including an XPointer fragment through the xml:id attribute as in your case:

Code: Select all

 <Nom Init="DF" xml:id="A1" >
but the element

Code: Select all

<xi:include href="testXI.xml" xpointer="A1" xmlns:xi="http://www.w3.org/2001/XInclude"/>
includes the entire element Nom.


Regards,
Sorin

Posted: Mon Nov 27, 2006 3:01 pm
by manuel.dorne
Thanks for your quick answer !

Posted: Mon Nov 27, 2006 3:04 pm
by manuel.dorne
Hi again !

When i generate the result file, i get this

<Text>
Voici les noms des personnes de la société
<Noms xml:base="testXi.xml">
<Nom Init="DF"><LastName>Faveur</LastName><FirstName>David</FirstName></Nom>
<Nom Init="MD"><LastName>Dorne</LastName><FirstName>Manuel</FirstName></Nom>
<Nom Init="PR"><LastName>Rajaud</LastName><FirstName>Patrick</FirstName></Nom>
</Noms>
</Text>

But, this file is not valid with my XSD because of the xml:base="textXi.xml" !
Do you know how to remove residual element like xml:base on my final generated file ?

Thanks

Posted: Mon Nov 27, 2006 3:27 pm
by sorin_ristache
manuel.dorne wrote:Do you know how to remove residual element like xml:base on my final generated file ?
You can avoid generating the xml:base attribute by disabling the Base URI fix-up option in Options -> Preferences -> XML -> XML Parser but generally this is not recommended. Why don't you modify your XSD to allow the xml:base attribute ?


Regards,
Sorin

Posted: Mon Nov 27, 2006 5:10 pm
by sorin_ristache
manuel.dorne wrote:When i generate the result file, i get this

<Text>
Voici les noms des personnes de la société
<Noms xml:base="testXi.xml">
<Nom Init="DF"><LastName>Faveur</LastName><FirstName>David</FirstName></Nom>
<Nom Init="MD"><LastName>Dorne</LastName><FirstName>Manuel</FirstName></Nom>
<Nom Init="PR"><LastName>Rajaud</LastName><FirstName>Patrick</FirstName></Nom>
</Noms>
</Text>
Use the XPointer expression which I specified to obtain only the FirstName element that you want. With the following XInclude element

Code: Select all

<xs:appinfo>
<Actions>
<xi:include href="testXI.xml" xpointer="element(/1/1/2)" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</Actions>
</xs:appinfo>
you get

Code: Select all

<xs:appinfo>
<Actions>
<FirstName xml:base="test2.xml">David</FirstName>
</Actions>
</xs:appinfo>

Regards,
Sorin