Hello ashok,
ashok _ wrote:
I am trying to parse an ODT document using XSLT (using the Saxon
processor).
Using similar technology ourselves, in particular using XSLT 2.0 with
Saxon B 9 (and are very happy that Saxon 9 has now made it
into OOo 3 - thank you Svante).
..the document has overlapping reference marks... e.g. :
<text:p>
<text:reference-mark-start text:name="one"/>this sentence has
<text:reference-mark-start text:name="two"/>overlapping
<text:reference-mark-end text:name="one"/>reference marks.
<text:reference-mark-end text:name="two"/>
</text:p>
ODF seems to use different elements for marking start / end regions of
a reference...is there a straightforward way to match content within
the start and end points of a reference mark...using XSLT ?
If you want the content for an individual, named region you could
use templates such as these:
<xsl:template
match="text()[following::text:[EMAIL PROTECTED]:name='one'] and
preceding::text:[EMAIL PROTECTED]:name='one']]">
<xsl:copy/>
</xsl:template>
<xsl:template
match="text()[following::text:[EMAIL PROTECTED]:name='two'] and
preceding::text:[EMAIL PROTECTED]:name='two']]">
<xsl:copy/>
</xsl:template>
But this code, while simple, may have two problems, depending on what
you are trying to do:
- you'd have to use a multi-pass or moded approach to your
XSLT processing if you wanted the different (overlapping)
content separately.
- you may not know the ids being used to mark the regions in advance.
An alternative approach may be to match="text()" and then write an
XPath/xsl:if which says: do I have a preceding::text:reference-mark-start
without a preceding::text:reference-mark-end with the same id?
If so, you are in that region with that id. If you then did that
for all of the preceding::text:reference-mark-start elements
you could build up a 'set', or more correctly an XPath sequence,
of ids of the regions that surround the current text() node.
XSLT2 functions help when writing code like the above. I didn't
complete the above code because I wasn't sure if that is what
you needed.
If you just want to know if you are in any region then
text()[count(preceding::text:reference-mark-start) !=
count(preceding::text:reference-mark-end)]
may help (assuming correct id matching/validity).
Cheers,
Nigel
--
Nigel Whitaker, DeltaXML: "Change control for XML and ODF"
[EMAIL PROTECTED] http://www.deltaxml.com
Free ODT Comparison service: http://www.deltaxml.com/services/odt/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]