XPath 2.0 dynamic generation of CSV file
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 42
- Joined: Sun Jul 15, 2012 12:26 pm
- Location: London
XPath 2.0 dynamic generation of CSV file
Hello all,
I have an XML file that is structured similar to this:
I also have an XSLT that I use to extract the /foo/bar/items/item elements as CSV. However, what I would really like to do is make the transformer dynamic so that I can set some params to tell it that I want to extract ./items/* or ./sets/* as CSV.
Is this doable? I would appreciate your thoughts on this please.
This is being built and tested using the IDE but will be end up in a Java application.
--
William
I have an XML file that is structured similar to this:
Code: Select all
<foo>
<bar>
<items>
<item/>
<item/>
<.../>
</items>
<sets>
<set/>
<set/>
<.../>
</sets>
<items>
<item/>
<item/>
<.../>
</items>
<sets>
<set/>
<set/>
<.../>
</sets>
</bar>
</foo>
Is this doable? I would appreciate your thoughts on this please.
This is being built and tested using the IDE but will be end up in a Java application.
--
William
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XPath 2.0 dynamic generation of CSV file
Hi,
It is doable, but it depends on how your XSLT is written.
Note that you can't use variables or parameters in the patterns from xsl:template/@match, but you can use them in xsl:for-each.
Here's a simple example:
Regards,
Adrian
It is doable, but it depends on how your XSLT is written.
Note that you can't use variables or parameters in the patterns from xsl:template/@match, but you can use them in xsl:for-each.
Here's a simple example:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<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:param name="groupName" select="'sets'"/>
<xsl:param name="itemName" select="'set'"/>
<xsl:template match="/">
<xsl:for-each select="//*[name() = $groupName]">
<!-- Per group -->
<xsl:for-each select="*[name() = $itemName]">
<!-- Per item -->
<xsl:message select="text()"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
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