newline in xml out put
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Fri Sep 18, 2009 8:55 pm
newline in xml out put
Hi,
I am trying to out put the contents of xml file in the form of html table. Data within xml tags displayed as individual rows data.
for example:
<Cd>
<songs>
1. BillieJean
2. Read my heart
3. No where to go
</songs>
<songs>
1. Bad
2. I am sorry
3. Jump on train
</songs>
</Cd>
My xslt outputs the data in the form of html table with
<xsl:for-each select="Cd/songs">
<xsl:value-of select="."/>
</xsl:for-each>
My problem is the output comes as a single line in these rows
(1. BillieJean2. Read my heart3. No where to go). I want these be displayed as individual lines withis the each row of table.
(
1. Bad
2. I am sorry
3. Jump on train
) Just like what I see in xml file.
I tried all sorts <xsl:text>
</xsl:text> and newline characters but I am unable to produce the desired results.
Can any one please suggest what changes I need to do to get the desired results?
Thank you in advance.
I am trying to out put the contents of xml file in the form of html table. Data within xml tags displayed as individual rows data.
for example:
<Cd>
<songs>
1. BillieJean
2. Read my heart
3. No where to go
</songs>
<songs>
1. Bad
2. I am sorry
3. Jump on train
</songs>
</Cd>
My xslt outputs the data in the form of html table with
<xsl:for-each select="Cd/songs">
<xsl:value-of select="."/>
</xsl:for-each>
My problem is the output comes as a single line in these rows
(1. BillieJean2. Read my heart3. No where to go). I want these be displayed as individual lines withis the each row of table.
(
1. Bad
2. I am sorry
3. Jump on train
) Just like what I see in xml file.
I tried all sorts <xsl:text>
</xsl:text> and newline characters but I am unable to produce the desired results.
Can any one please suggest what changes I need to do to get the desired results?
Thank you in advance.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: newline in xml out put
Post by sorin_ristache »
Hello,
I don't understand how you get the concatenated lines of a songs element in the output. If the text lines of a songs element are separated with a newline in the XML file they are separated in the output of the transformation too because <xsl:value-of select="."/> will copy the content of the songs element without changing it. You can see that with the following two files:
test.xml:
test.xsl:
Regards,
Sorin
I don't understand how you get the concatenated lines of a songs element in the output. If the text lines of a songs element are separated with a newline in the XML file they are separated in the output of the transformation too because <xsl:value-of select="."/> will copy the content of the songs element without changing it. You can see that with the following two files:
test.xml:
Code: Select all
<Cd>
<songs>
1. BillieJean
2. Read my heart
3. No where to go
</songs>
<songs>
1. Bad
2. I am sorry
3. Jump on train
</songs>
</Cd>
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="Cd/songs">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: newline in xml out put
Post by sorin_ristache »
That was for text output. If you want to put the content of a songs element in an HTML table you have to parse the text content of each songs element and separate the lines in the output with an element <br />.
Regards,
Sorin
Regards,
Sorin
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