| Author |
where am i going wrong in my xsl transformation
|
john mattucci
Ranch Hand
Joined: Nov 03, 2000
Posts: 331
|
|
I have the following .xml with the following struncture <records> <record> <author> <event_time> .... </record> ... I then whish to transfer it to text to be included within an email. Im trying to align all the columns so that the document is easier to read. So Im attepting to read the element and check if its of length 20 and if not keep looping adding whitespaces until you reach 20. My problem now is that nothing happens. Where am I going wrong in my xsl document. Thank you for your time <xsl utput method="text" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="records"/> </xsl:template> <xsl:template name="author" match="author"> <xsl aram name="aut"><xsl:value-of select="."/></xsl aram> <xsl:choose> <xsl:when test="string-length('$aut') < 20"><xsl:call-template name="author"> <xsl:with-param name="aut" select="concat('$aut', ' ')"/> </xsl:call-template></xsl:when> <xsl:when test="string-length('$aut') = 20"><xsl:value-of select="$aut"/><xsl:text> </xsl:text></xsl:when> </xsl:choose> </xsl:template>
|
 |
Dhananjay Goswami
Greenhorn
Joined: Jan 28, 2003
Posts: 18
|
|
The line causing the problem is the <xsl:apply-templates select="records"/>. and you don't have the template for 'records' defined anywhere. Try changing this to: <xsl:apply-templates select="author"/> or create a template for 'records' and call the 'author' template eith the corresponding parameter. All the best. Dhananjay.
|
 |
john mattucci
Ranch Hand
Joined: Nov 03, 2000
Posts: 331
|
|
I tried the following and i still get no output Any ideas? <xsl:template match="/"> <xsl:for-each select="records/record"> <xsl:apply-templates select="author"/> </xsl:for-each> </xsl:template> <!--<xsl:template match="record">--> <!--<xsl:number/>.--> <xsl:template name="author" match="author"> <xsl aram name="aut"><xsl:value-of select="."/></xsl aram> <xsl:choose> <xsl:when test="string-length('$aut') < 20"><xsl:call-template name="author"> <xsl:with-param name="aut" select="concat('$aut', ' ')"/> </xsl:call-template></xsl:when> <xsl:when test="string-length('$aut') = 20"><xsl:value-of select="$aut"/><xsl:text> </xsl:text></xsl:when> </xsl:choose> </xsl:template>
|
 |
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
|
|
It can be easier to define a variable of 20 blanks <xsl:variable name="twentyBlanks"> *</xsl:variable> (doesn't work without "*" at the end) and then cut as many blanks as you need to lengthen your aut variable: <xsl:variable name="test" select="concat( $aut, substring($twentyBlanks, 1, 20 - string-length($aut)) )"/>* [ March 10, 2003: Message edited by: Mapraputa Is ]
|
Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
|
 |
 |
|
|
subject: where am i going wrong in my xsl transformation
|
|
|