The second alternative’s variable holds in fact a document node,
according to
http://www.w3.org/TR/xslt20/#variable-values
“If a variable-binding element has no select attribute and has non-empty
content (that is, the variable-binding element has one or more child
nodes), and has no as attribute, then the content of the
variable-binding element specifies the supplied value. The content of
the variable-binding element is a sequence constructor; a new document
is constructed with a document node having as its children the sequence
of nodes that results from evaluating the sequence constructor and then
applying the rules given in 5.7.1”
If you want to make it a topic element, you should explicitly declare
the variable as such:
<xsl:variable name="containingChapter" as="element(topic)">
Gerrit
On 2012-12-21 00:24, Steve Fogel wrote:
Hi, all.
Would appreciate some help. I don't understand how these two definitions of a
variable produce different results. This is from the DITA Open Toolkit (OT).
1st alternate definition is without a condition:
<xsl:variable name="containingChapter"
select="ancestor-or-self::*[contains(@class, ' topic/topic
')][position()=last()]"/>
2nd alternate definition is with a condition, which is me fixing a bug in the
(OT).
<xsl:variable name="containingChapter">
<xsl:choose>
<xsl:when test="$hasBookParts"> <!-- The book has <part>s -->
<xsl:copy-of select="ancestor-or-self::*[contains(@class, ' topic/topic
')][last()-1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="ancestor-or-self::*[contains(@class, ' topic/topic
')][last()]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Both definitions should return a <topic> element with an id attribute.
Following the definition is this statement:
<xsl:variable name="id" select="$containingChapter/@id"/>
With the first definition, the value of id is a string, as desired. With the
2nd, it's empty. Bad. Why?
For the 1st definition, the Oxygen debugger gives the value type as "element(1)". For the
2nd, it gives the value type as "document-node(1)". In fact, if you look at the value of
the variable in Oxygen's Nodes/Values Set window, for the 1st definition it is:
topic
and for the 2nd, it is:
#document/fragment
topic
Can someone please advise?
Many thanks!
Steve
Steve Fogel | Information Architect, Oracle Database | 650.506.4914
Oracle Server Technologies Information Development
500 Oracle Parkway | M/S 4op1126 | Redwood Shores, CA 94065
--~------------------------------------------------------------------
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>
--~--
--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930
Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~------------------------------------------------------------------
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>
--~--