Why are the white spaces in my xml file not
maintained? There are some white spaces(mutliple ws)
and it only outputs one. I read that
<xsl:perserve-space elements="transaction_data" does
not need to be called b/c it is the default. How can
I maintain those white spaces?
--- cknell(_at_)onebox(_dot_)com wrote:
Since the <transaction_detail> element is a child of
<row> and not the root element of the document, you
must lose the intial "/" in the XPath selecting it.
In other words, change this:
<xsl:value-of select="/transaction_detail"/>
to this:
<xsl:value-of select="transaction_detail"/>
On a more fundamental note. There appears to be no
reason to use for-each here. Switch to the more
natural (for XSLT) <xsl:apply-templates> approach.
Taking a few liberties with the unstated parts of
your transformation, this is the stylesheet I
recommend:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes"
encoding="UTF-8" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="base">
<fo:region-body region-name="body"
margin-top="0.5in"
margin-bottom="0.5in"
margin-left="0.5in"
margin-right="0.5in" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="base">
<fo:flow flow-name="body">
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="invoice">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="detail">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="row">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="transaction_detail">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="line_sequence" />
<xsl:template match="format_control" />
<xsl:template match="group_no" />
</xsl:stylesheet>
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
-----Original Message-----
From: josh higgins <doopsterus(_at_)yahoo(_dot_)com>
Sent: Fri, 1 Apr 2005 11:47:15 -0800 (PST)
To: xsl <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: [xsl] xls:for-each not working
I cannot get my for-each statement to work. Am I
doing this incorrectly? I am just wanting to
output
all of the data in the xml file that has a
<transaction_data> tag. Here is my statement and
below is the sample xml. I use this to attempt to
display my template <xsl:call-template
name="detail"/>
Please help!
Thanks!
Josh
<xsl:template name="detail">
<xsl:for-each select="/invoice/detail/row">
<fo:block>
<xsl:value-of select="/transaction_detail"/>
</fo:block>
</xsl:for-each>
</xsl:template>
SAMPLE XML
<invoice>
<detail>
<row>
<line_sequence>1</line_sequence>
<transaction_detail>Activity for (620)
251-1559</transaction_detail>
<format_control>C1</format_control>
<group_no>1</group_no>
</row>
<row>
<line_sequence>2</line_sequence>
<group_no>1</group_no>
</row>
<row>
<line_sequence>3</line_sequence>
<transaction_detail> Transaction
Activity</transaction_detail>
<format_control>C1</format_control>
<group_no>1</group_no>
</row>
<row>
<line_sequence>4</line_sequence>
<format_control>U1</format_control>
<group_no>1</group_no>
</row>
<row>
<line_sequence>5</line_sequence>
<transaction_detail>
Description</transaction_detail>
<group_no>1</group_no>
</row>
<row>
<line_sequence>6</line_sequence>
<transaction_detail>
============================================================================</transaction_detail>
<group_no>1</group_no>
</row>
</detail>
</invoice>
__________________________________
Do you Yahoo!?
Yahoo! Personals - Better first dates. More second
dates.
http://personals.yahoo.com
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
__________________________________
Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.
http://www.advision.webevents.yahoo.com/emoticontest
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--