R
Rach
Hi,
I'd like to model the following using schema definition (XSD) and I'd like
to express paths using (XPath).
1. Is it possible to define a xsd for rootBook? As you can see, a <rootBook>
can contain inline <chapter> definition and references to a loose <chapter>
outside of <rootBook>.
<rootBook>
<chapter id="1">
<paragraph>Para 1</paragraph>
<paragraph>Para 2</paragraph>
<paragraph>Para 3</paragraph>
</chapter>
<chapter ref="2"/>
</rootBook>
<chapter id="2">
<paragraph>Para 4</paragraph>
<paragraph>Para 5</paragraph>
<paragraph>Para 6</paragraph>
</chapter>
2. And then how do I define "one" XPath expression that caters for both
inline and external chapters?
expression: //rootBook/chapter[@id="1"]/*
returns:
/rootBook[1]/chapter[1]/paragraph[1] - Para 1
/rootBook[1]/chapter[1]/paragraph[2] - Para 2
/rootBook[1]/chapter[1]/paragraph[3] - Para 3
I want this expression to return me the following to, when the queried id is
"2":
/rootBook[1]/chapter[2]/paragraph[1] - Para 4
/rootBook[1]/chapter[2]/paragraph[2] - Para 5
/rootBook[1]/chapter[2]/paragraph[3] - Para 6
Many thanks.
-rach
I'd like to model the following using schema definition (XSD) and I'd like
to express paths using (XPath).
1. Is it possible to define a xsd for rootBook? As you can see, a <rootBook>
can contain inline <chapter> definition and references to a loose <chapter>
outside of <rootBook>.
<rootBook>
<chapter id="1">
<paragraph>Para 1</paragraph>
<paragraph>Para 2</paragraph>
<paragraph>Para 3</paragraph>
</chapter>
<chapter ref="2"/>
</rootBook>
<chapter id="2">
<paragraph>Para 4</paragraph>
<paragraph>Para 5</paragraph>
<paragraph>Para 6</paragraph>
</chapter>
2. And then how do I define "one" XPath expression that caters for both
inline and external chapters?
expression: //rootBook/chapter[@id="1"]/*
returns:
/rootBook[1]/chapter[1]/paragraph[1] - Para 1
/rootBook[1]/chapter[1]/paragraph[2] - Para 2
/rootBook[1]/chapter[1]/paragraph[3] - Para 3
I want this expression to return me the following to, when the queried id is
"2":
/rootBook[1]/chapter[2]/paragraph[1] - Para 4
/rootBook[1]/chapter[2]/paragraph[2] - Para 5
/rootBook[1]/chapter[2]/paragraph[3] - Para 6
Many thanks.
-rach