XM to XSLT Newbie
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 8
- Joined: Tue Oct 02, 2012 4:53 am
XM to XSLT Newbie
Hello Gurus,
I'm new to XSLT and have so far only seen XML documents. But now I have been given a task to convert a XML document to XSLT. I downloaded Oxygen but do not know where to start etc.
If I have this dummy.xml file.How would I start this in Oxygen and write code for xslt and see th output as pipe delimited file. Output should be Professional JINI|Sing Li|Wrox Publications.
I know i'm probably asking the basic question, but since im new to this technology and the tool, I thought I would ask for help. Any help will be greatly appreciated.
Thanks
Ash
I'm new to XSLT and have so far only seen XML documents. But now I have been given a task to convert a XML document to XSLT. I downloaded Oxygen but do not know where to start etc.
If I have this dummy.xml file.How would I start this in Oxygen and write code for xslt and see th output as pipe delimited file. Output should be Professional JINI|Sing Li|Wrox Publications.
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1" ?>
<LIBRARY>
<BOOK>
<TITLE>Professional JINI</TITLE>
<AUTHOR>Sing Li</AUTHOR>
<PUBLISHER>Wrox Publications</PUBLISHER>
</BOOK>
</LIBRARY>
Thanks
Ash
-
- Posts: 8
- Joined: Tue Oct 02, 2012 4:53 am
Re: XM to XSLT Newbie
After playing a bit with the tool, I was able to create the xslt file. However, I have few questions.
1) How do I do if conditions?
Say an employee has Prefefferd Last Name and Legal Last name
So the condition should say If Preferred name exists the use preferred name else use Last name.
2) How do I check for null values? meaning if value is blank then i want to insert 'xxx' on the pipe delimited file
3) How do I use a running counter ?
Sorry for all these basic questions. Still getting my head around this.
Thanks
Ash
1) How do I do if conditions?
Say an employee has Prefefferd Last Name and Legal Last name
So the condition should say If Preferred name exists the use preferred name else use Last name.
2) How do I check for null values? meaning if value is blank then i want to insert 'xxx' on the pipe delimited file
3) How do I use a running counter ?
Sorry for all these basic questions. Still getting my head around this.
Thanks
Ash
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XM to XSLT Newbie
Hello,
1. Assuming you're in the context where the name and last name elements are specified:
You can use either xsl:if or xsl:choose:or
2. To check for empty values:
<xsl:if test="preferredLastNameElement/text()">
To check for values that contain only space characters:
<xsl:if test="normalize-space(preferredLastNameElement/text())">
3.Note that the XML context is lost inside this for-each, instead, the context(.) is the current value of the counter. So you may want to save the XML context in a variable before this.
e.g.
Regards,
Adrian
1. Assuming you're in the context where the name and last name elements are specified:
You can use either xsl:if or xsl:choose:
Code: Select all
<xsl:if test="preferredLastNameElement">
...
</xsl:if>
<xsl:if test="not(preferredLastNameElement)">
...
</xsl:if>
Code: Select all
<xsl:choose>
<xsl:when test="preferredLastNameElement">
...
</xsl:when>
<xsl:when test="legalLastNameElement">
...
</xsl:when>
</xsl:choose>
<xsl:if test="preferredLastNameElement/text()">
To check for values that contain only space characters:
<xsl:if test="normalize-space(preferredLastNameElement/text())">
3.
Code: Select all
<xsl:for-each select="1 to n">
...
</xsl:for-each>
e.g.
Code: Select all
<xsl:variable name="context" select="."/>
<xsl:for-each select="1 to n">
...
<xsl:value-of select="$context"/>
</xsl:for-each>
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