tricky transformation
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 3
- Joined: Mon Mar 14, 2005 1:45 am
tricky transformation
Hi,
I need an idea how to write a transformation for the following xml Dokument
<names>
<name>Jeffrey</name>
<name>George</name>
<name>Mike</name>
</name>
so that, when I use fop, the following line is created.
Jeffrey, George, Mike.
My problem is, that behind every name a comma is set, but behind the last one a dot.
I tried to do it like this:
<xsl:template match="names">
<fop:block>
<xsl:apply-templates/>
</fop:block>
</xsl:template>
<xsl:template match="name">
<xsl:value-of select="."/>,
</xsl:template>
but as you can see, this version sets a comma after every name, even after the last one.
Thanks a lot for any ideas, how to solve this problem.
I need an idea how to write a transformation for the following xml Dokument
<names>
<name>Jeffrey</name>
<name>George</name>
<name>Mike</name>
</name>
so that, when I use fop, the following line is created.
Jeffrey, George, Mike.
My problem is, that behind every name a comma is set, but behind the last one a dot.
I tried to do it like this:
<xsl:template match="names">
<fop:block>
<xsl:apply-templates/>
</fop:block>
</xsl:template>
<xsl:template match="name">
<xsl:value-of select="."/>,
</xsl:template>
but as you can see, this version sets a comma after every name, even after the last one.
Thanks a lot for any ideas, how to solve this problem.
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
You can check if there is a following sibling name element and in that case output comma, otherwise output the dot.
Something like:
Best Regards,
George
You can check if there is a following sibling name element and in that case output comma, otherwise output the dot.
Something like:
Code: Select all
<xsl:template match="name">
<xsl:value-of select="."/>
<xsl:choose>
<xsl:when test="following-sibling::name">
<xsl:text>,</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>.</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Best Regards,
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