[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] preceding-sibling inside for-each appears to fail
Hi,
I'm trying to get the value of an attribute in the preceding sibling inside a for-each loop. The code below successfully captures the following-sibling, but always returns the same output for the preceding-sibling. What am I doing wrong? Sample XML: <HtdigAttributes> <attribute name="accents_db" type="string" programs="htfuzzy htsearch" version="all" category="File Layout" > <default>${database_base}.accents.db</default> <example>${database_base}.uml.db</example> <description> The database file used for the fuzzy "accents" search algorithm. This database is created by <ref type="program">htfuzzy</ref> and used by <ref type="program">htsearch</ref>. </description> </attribute> <attribute name="accept_language" type="string_list" programs="htdig" version="3.2.0b4" category="Indexing:Out" block="Server" > <default></default> <example>en-us en it</example> <description> This attribute allows you to restrict the set of natural languages that are preferred as a response to an HTTP request performed by the digger. This can be done by putting one or more language tags (as defined by RFC 1766) in the preferred order, separated by spaces. By doing this, when the server performs a content negotiation based on the 'accept-language' given by the HTTP user agent, a different content can be shown depending on the value of this attribute. If set to an empty list, no language will be sent and the server default will be returned. </description> </attribute> <attribute name="add_anchors_to_excerpt" type="boolean" programs="htsearch" version="3.1.0" category="Presentation:How" > <default>true</default> <example>no</example> <description> If set to true, the first occurrence of each matched word in the excerpt will be linked to the closest anchor in the document. This only has effect if the <strong>EXCERPT</strong> variable is used in the output template and the excerpt is actually going to be displayed. </description> </attribute> </HtdigAttributes> Sample XSL: <xsl:template name="alphabet"> <xsl:for-each select="//HtdigAttributes/attribute"> <p>checking: <xsl:value-of select="@name" /></p> <p>preceding sibling = <xsl:value-of select="preceding-sibling::attribute/@name" /></p> <p>following sibling = <xsl:value-of select="following-sibling::attribute/@name" /></p> </xsl:for-each> </xsl:template> Sample Output: <p>checking: accents_db</p> <p>preceding sibling = </p> <p>following sibling = accept_language</p> <p>checking: accept_language</p> <p>preceding sibling = accents_db</p> <p>following sibling = add_anchors_to_excerpt</p> <p>checking: add_anchors_to_excerpt</p> <p>preceding sibling = accents_db</p> <p>following sibling = allow_double_slash</p> <p>checking: allow_double_slash</p> <p>preceding sibling = accents_db</p> <p>following sibling = allow_in_form</p> Discussion As you can see, following-sibling successfully returns the following sibling, but preceding-sibling always returns the first node rather than the preceding-sibling node. I've tried changing the way I'm referencing the node values to no avail. I would greatly appreciate any pointers in what I'm doing wrong here. Sincerely, Ted Stresen-Reuter XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|