Subject: Re: [xsl] handling of xsl-Variable in formatting text From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 15 Apr 2016 12:42:37 -0000 |
It would help to give a complete executable stylesheet (preferably with irrelevant detail removed) and a source document, plus expected output, so people can run it for themselves and debug it for you. As it is, we can only stare at the code - you haven't even told us what the failure symptoms are ("it doesn't work" isn't very helpful...) One thing I would suggest it to cut out the whitespace in the variable value, which at best is unnecessary and at worst could cause downstream processing to produce the wrong results: > <xsl:choose> > <xsl:when test="@pnr != '7000'">normal</xsl:when> > <xsl:otherwise>bold</xsl:otherwise> > </xsl:choose> Not being able to see a source document, I don't know if it's relevant, but you should be aware of the exact meaning of "@pnr != '7000'" - it means "if the pnr attribute exists and has a value other than '7000'. Writing "not(@pnr = '7000')" has a different meaning when the attribute is absent. Michael Kay Saxonica > On 15 Apr 2016, at 12:45, Dirk Naujoks naujoks@xxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Good day, > > i am a little mixed up how to use a once set xsl-variable. > I tried the following code > > > Start Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > <xsl:template name="pruefung"> > <xsl:variable name="outline"> > <xsl:choose> > <xsl:when test="@pnr != '7000'"> > normal > </xsl:when> > <xsl:otherwise> > bold > </xsl:otherwise> > </xsl:choose> > </xsl:variable> > <fo:table-row keep-with-next.within-column="always" > padding-bottom="1pt" padding-top="1.0pt"> > <fo:table-cell number-columns-spanned="6" > padding-before="0pt"> > <fo:block space-before="0pt"> > <fo:leader leader-pattern="rule" rule-thickness="0.5pt" > leader-length="17cm" color="white" /> > </fo:block> > </fo:table-cell> > </fo:table-row> > <fo:table-row keep-together.within-column="always" > padding-bottom="1pt" padding-top="1pt" line-height="10pt"> > <fo:table-cell padding-right="3pt"> > <fo:block span="none" font-family="OfficinaSansLT" > font-size="{$schrifta}" font-weight="{$outline}" text-align="start"> > <xsl:value-of disable-output-escaping="no" select="@pnr" /># > <xsl:value-of disable-output-escaping="no" select="@psem" /> > <xsl:value-of disable-output-escaping="no" select="$outline" /> > </fo:block> > </fo:table-cell> > <fo:table-cell padding-right="5pt"> > <fo:block span="none" font-family="OfficinaSansLT" > font-size="{$schrifta}" text-align="start"> > <xsl:choose> > <xsl:when test="@pnr != '7000'"> > <xsl:value-of disable-output-escaping="no" select="@deTxt" /> > </xsl:when> > <xsl:otherwise> > Note der fachpraktischen PrC<fung > </xsl:otherwise> > </xsl:choose> > </fo:block> > </fo:table-cell> > <fo:table-cell padding-right="5pt"> > <fo:block span="none" font-family="OfficinaSansLT" > font-size="{$schrifta}" text-align="start" font-weight=""> > <xsl:if test="@pstatus = 'AN'"> > <xsl:value-of disable-output-escaping="no" select="@pstatus" /> > </xsl:if> > <xsl:if test="@pstatus = 'EN'"> > <xsl:value-of disable-output-escaping="no" select="@pstatus" /> > </xsl:if> > </fo:block> > </fo:table-cell> > <fo:table-cell padding-right="3pt"> > <fo:block span="none" font-family="OfficinaSansLT" > font-size="{$schrifta}" text-align="center" font-weight=""> > <xsl:if test="@pnote != '' and @pnote != ' '"> > <xsl:if test="@panerk = 'J'"> > <xsl:variable name="anerk"> > * > </xsl:variable> > <xsl:value-of > select="concat(substring(@pnote,1,1),',',substring(@pnote,2,1),' ',$anerk)" /> > </xsl:if> > <xsl:if test="not(@panerk)"> > <xsl:value-of > select="concat(substring(@pnote,1,1),',',substring(@pnote,2,1))" /> > </xsl:if> > <xsl:if test="@panerk = 'N'"> > <xsl:value-of > select="concat(substring(@pnote,1,1),',',substring(@pnote,2,1))" /> > </xsl:if> > </xsl:if> > </fo:block> > </fo:table-cell> > <fo:table-cell padding-right="5pt"> > <fo:block span="none" font-family="OfficinaSansLT" > font-size="{$schrifta}" text-align="start" font-weight=""> > <xsl:if test="@panerk = 'J'"></xsl:if> > </fo:block> > </fo:table-cell> > </fo:table-row> > <xsl:for-each select="veranst"> > <xsl:call-template name="veranst" /> > </xsl:for-each> > </xsl:template> > End Code~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The variable "schrifta" works fine it is set at the beginning of the xsl-Document. > The variable "outline" doesn't work it is set. i can confirm it by using "<xsl:value-of disable-output-escaping="no" select="$outline" />" somewhere in the code e.g. after the select of psem at the beginning of this code-sniplet. > > I can't format the text for the data with the pnr=7000 in the right way. Has anybody an idea how to fix it? > > Thanks for your help in advance.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] handling of xsl-Variable in f, Dirk Naujoks naujoks | Thread | Re: [xsl] handling of xsl-Variable , Dirk Naujoks naujoks |
[xsl] handling of xsl-Variable in f, Dirk Naujoks naujoks | Date | Re: [xsl] handling of xsl-Variable , Dirk Naujoks naujoks |
Month |