How to declare a variable
Posted: Fri May 29, 2015 10:27 pm
Hello,
We have two types of documents to generate, one that requires chapter numbering, and the other requires no numbering. I was able to create a condition in the custom.xsl file to generate the document with or without numbering base on the book title. Obviously putting a condition on a book title does not work since are documents don't all have the same name.
I tried using <xsl:when test="($otherprops='number')">
But I get an error message saying that Variable otherprops is undeclared. How and where can I declare this variable? Or is there another variable I should be using. This variable needs to be associated to the ditamap.
Kind regards
Carole
Here is the code I used.
test="($bookTitle='number')">[/b]
<xsl:for-each select="$mapTopics[1]">
<xsl:choose>
<!--xsl:when test="parent::opentopic:map"/-->
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ') or contains(@class, ' bookmap/backmatter ')]" />
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]">
<xsl:number count="*[contains(@class, ' map/topicref ')] [ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]]" format="A.1.1" level="multiple" />
</xsl:when>
<xsl:otherwise>
<xsl:number count="*[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ')])]" format="1.1" level="multiple" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</fo:inline>
<xsl:text> </xsl:text>
<xsl:apply-templates />
</xsl:template>
[/code]
We have two types of documents to generate, one that requires chapter numbering, and the other requires no numbering. I was able to create a condition in the custom.xsl file to generate the document with or without numbering base on the book title. Obviously putting a condition on a book title does not work since are documents don't all have the same name.
I tried using <xsl:when test="($otherprops='number')">
But I get an error message saying that Variable otherprops is undeclared. How and where can I declare this variable? Or is there another variable I should be using. This variable needs to be associated to the ditamap.
Kind regards
Carole
Here is the code I used.
Code: Select all
[code]<xsl:template match="*" mode="getTitle">
<xsl:variable name="topic" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]" />
<xsl:variable name="id" select="$topic/@id" />
<xsl:variable name="mapTopics" select="key('map-id', $id)" />
<fo:inline>
<xsl:choose>
[b] <xsl:when
<xsl:for-each select="$mapTopics[1]">
<xsl:choose>
<!--xsl:when test="parent::opentopic:map"/-->
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ') or contains(@class, ' bookmap/backmatter ')]" />
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]">
<xsl:number count="*[contains(@class, ' map/topicref ')] [ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]]" format="A.1.1" level="multiple" />
</xsl:when>
<xsl:otherwise>
<xsl:number count="*[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ')])]" format="1.1" level="multiple" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</fo:inline>
<xsl:text> </xsl:text>
<xsl:apply-templates />
</xsl:template>
[/code]