xsl-list
[Top] [All Lists]

RE: Recognize nested element (check for same-name parent)

2005-02-09 09:27:48
David,

   <xsl:if test="parent::step">

Worked like a charm. Thanks.

No!  You can never access or insetr or in any way manipulate 
tags in XSLT. You can't add a start tag in one place and an 
end tag somewhere else. XSLT works on node trees and you 
can't have half a node.

I know, I've been cheating with:
<xsl:text disable-output-escaping="yes">&lt;ol&gt;</xsl:text>

My XSLT so far is:

<xsl:template match="step">
        <xsl:if test="parent::step">
                <xsl:if test="position()=1">
                        <xsl:text
disable-output-escaping="yes">&lt;ol&gt;</xsl:text>
                </xsl:if>
                <li>
                        <xsl:apply-templates/></li>
                <xsl:if test="position()=last()">
                        <xsl:text
disable-output-escaping="yes">&lt;/ol&gt;</xsl:text>
                </xsl:if>
        </xsl:if>
        <li>
                <xsl:apply-templates/></li>
        </xsl:template>

My end result is a procedural document, with numbered steps from 1 to
say 100, and section headings inbetween like PREPARE, REMOVE PART, FIT
PART, ADJUST PART, FINALIZE, and these do not restart the numbering. So
I have already started an <ol> as soon as I see the first section, and
so the first level <step> only needs a <li> tag around it, while the
second/third needs a <ol> before the first and after the last.
I'm trying to accomplish:

XML:

<section>
  <title>PREPARE</title>
  <step>Step 1.</step>
  <step>Do as follows:
    <step>Select: Start</step>
    <step>Select: Yes</step>
  </step>
</section>
<section>
  <title>REMOVE PART</title>
  <step>Step 3.</step>
  <step>Do as follows:
    <step>Select: Initialize Motor</step>
    <step>Select: Yes</step>
  </step>
</section>

Desired output HTML:

PREPARE
 1. Step 1.
 2. Do as follows:
     2.1. Select: Start
     2.2. Select: Yes
REMOVE PART
 3. Step 3.
 4. Do as follows:
     4.1 Select: Initialize Motor
     4.2 Select: Yes


Regards,

Cas







-- 
The information contained in this communication and any attachments is 
confidential and may be privileged, and is for the sole use of the intended 
recipient(s). Any unauthorized review, use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify the sender 
immediately by replying to this message and destroy all copies of this message 
and any attachments. ASML is neither liable for the proper and complete 
transmission of the information contained in this communication, nor for any 
delay in its receipt.


--~------------------------------------------------------------------
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>
--~--