Select multiple child nodes
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 6
- Joined: Mon Sep 29, 2008 2:32 pm
Select multiple child nodes
I'm fairly new to XSLT, and struggeling with something that I think should be really simple.
Given the following XML, how can you select the last w:r-element only? (I want to tag the last text with "BoldItalic". )
Given the following XML, how can you select the last w:r-element only? (I want to tag the last text with "BoldItalic". )
Code: Select all
<w:p>
<w:r>
<w:rPr>
<w:i/>
</rPr>
<w:t>Some italic text, </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</rPr>
<w:t>followed by bold text</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:rPr>
<w:i/>
<w:b/>
</rPr>
<w:t>But what about both?</w:t>
</w:r>
</w:p>
Code: Select all
<xsl:template match="w:r/w:rPr/w:i">
<!--do something here-->
</xsl:template>
<xsl:template match="w:r/w:rPr/w:b">
<!--do something here-->
</xsl:template>
-
- Posts: 12
- Joined: Wed Oct 31, 2007 1:25 pm
Re: Select multiple child nodes
Code: Select all
<root>
<p>
<r>
<rPr>
<i/>
</rPr>
<t>Some italic text, </t>
</r>
<r>
<rPr>
<b/>
</rPr>
<t>followed by bold text</t>
</r>
</p>
<p>
<r>
<rPr>
<i/>
<b/>
</rPr>
<t>But what about both?</t>
</r>
</p>
</root>
Code: Select all
<xsl:template match="root">
<xsl:apply-templates select="descendant::r[last()]"/>
</xsl:template>
Code: Select all
<xsl:template match="root">
<xsl:apply-templates select="descendant::r[not(following-sibling::r)]"/>
</xsl:template>
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