XSL for XML
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 1
- Joined: Sat Jun 04, 2022 2:18 am
XSL for XML
Hello,
i have below xml, having difficulty in generating xsl for this. I would like to separate this into two files based on testbook-id. I am able to list them, but not sure how can I separate them into two files.
Any help would be greatly appreciated.
here is the sample xml
i have below xml, having difficulty in generating xsl for this. I would like to separate this into two files based on testbook-id. I am able to list them, but not sure how can I separate them into two files.
Any help would be greatly appreciated.
here is the sample xml
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<testbooks xmlns="SOME_NS">
<testbook>
<header testbook-id="ca-cad-list">
<currency>CAD</currency>
<online-flag>true</online-flag>
</header>
<price-tables>
<price-table product-id="035:M:1:">
<online-from>2022-06-02T00:00:00.000Z</online-from>
<online-to>9999-12-31T23:59:59.000Z</online-to>
<amount quantity="1">90.00 </amount>
</price-table>
</price-tables>
</testbook>
<testbook>
<header testbook-id="ca-cad-sale">
<currency>CAD</currency>
<online-flag>true</online-flag>
</header>
<price-tables>
<price-table product-id="035:M:1:">
<online-from>2022-06-02T00:00:00.000Z</online-from>
<online-to>9999-12-31T23:59:59.000Z</online-to>
<amount quantity="1">85</amount>
</price-table>
</price-tables>
</testbook>
</testbooks>
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: XSL for XML
Hi,
You can use the XSLT result-document function to create multiple files on disk, something like this for example:
Regards,
Radu
You can use the XSLT result-document function to create multiple files on disk, something like this for example:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*:testbook">
<xsl:result-document href="{*:header/@testbook-id}">
<xsl:apply-templates/>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
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