XSL: inserting a new element below a sibling
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Mon Apr 04, 2005 3:52 pm
XSL: inserting a new element below a sibling
Hi,
I need to be able to insert a new element which will be a sibling an an existing element.
The xml is too large to post but i will provide an exampole for this purpose. The XML structuire would be simular to this:
<task>
<temp>
</temp>
<trial>
</trial>
<floppy>
</floppy>
<spain>
</spain>
</task>
what i need to be able to do is add a new element below the floppy element and above the spain element.
The xsl i have only inserts it immediately below the <task> element.
Thanks for any help.
I need to be able to insert a new element which will be a sibling an an existing element.
The xml is too large to post but i will provide an exampole for this purpose. The XML structuire would be simular to this:
<task>
<temp>
</temp>
<trial>
</trial>
<floppy>
</floppy>
<spain>
</spain>
</task>
what i need to be able to do is add a new element below the floppy element and above the spain element.
The xsl i have only inserts it immediately below the <task> element.
Thanks for any help.
-
- Posts: 2
- Joined: Mon Apr 04, 2005 3:52 pm
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
Try something like below:
Regards,
George
Try something like below:
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="spain">
<newElement/>
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</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