xsl attribute value(pre order and post order)
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 6
- Joined: Sun Mar 27, 2005 10:29 pm
xsl attribute value(pre order and post order)
Hi all,
I have a small problem on xsl..i need to design an xsl stylesheet to output one line for each element, in preorder and postorder, which contains the id values for the element and its successor and predecessor.
thanks
I have a small problem on xsl..i need to design an xsl stylesheet to output one line for each element, in preorder and postorder, which contains the id values for the element and its successor and predecessor.
Code: Select all
<!DOCTYPE document (View Source for full doctype...)>
- <document id="d">
- <chapter id="dc1">
- <section id="dc1s1">
<topic id="dc1s1t1" />
<topic id="dc1s1t2" />
</section>
- <section id="dc1s2">
<topic id="dc1s2t1" />
<topic id="dc1s2t2" />
</section>
</chapter>
- <chapter id="dc2">
- <section id="dc2s1">
<topic id="dc2s1t1" />
<topic id="dc2s1t2" />
</section>
- <section id="dc2s2">
<topic id="dc2s2t1" />
<topic id="dc2s2t2" />
</section>
</chapter>
</document>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Something like below:
Regards,
George
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:text>Pre-order
</xsl:text>
<xsl:apply-templates select="." mode="pre"/>
<xsl:text>Post-order
</xsl:text>
<xsl:apply-templates select="." mode="post"/>
</xsl:template>
<xsl:template match="*" mode="pre">
<xsl:call-template name="display"/>
<xsl:apply-templates mode="pre"/>
</xsl:template>
<xsl:template match="text()" mode="pre"/>
<xsl:template match="*" mode="post">
<xsl:apply-templates mode="post"/>
<xsl:call-template name="display"/>
</xsl:template>
<xsl:template match="text()" mode="post"/>
<xsl:template name="display">
<xsl:text>[</xsl:text>
<xsl:value-of select="preceding::*/@id"/>
<xsl:text>][</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>][</xsl:text>
<xsl:value-of select="following::*/@id"/>
<xsl:text>]</xsl:text>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service