XSLT - XPATH - Expression

XSLT - XPATH - Expression

Post by J?rg Floth » Wed, 19 Dec 2001 21:49:12



XML

   <OL1>
         <LI>some text under OL1</LI>
         <LI>some text under OL1</LI>
         <LI>some text under OL1</LI> (tender point matching this node. The
two following OL2 shall be matched by this node)
         <OL2>
              <LI>some text under OL2</LI>
              <LI>some text under OL2</LI>
         </OL2>
         <OL2>
              <LI>some text under OL2</LI>
              <LI>some text under OL2</LI>
         </OL2>
         <LI>some text under OL1</LI>
         <LI>some text under OL1</LI>
         <OL2>                                  this "OL2" shall not be
matched by the current node, because it will be matched by the "LI" directly
above it.
              <LI>some text under OL2</LI>
              <LI>some text under OL2</LI>
         </OL2>
   </OL1>
****************************************************************************
**********************************
XSL

I have to accomplish the following XSLT - task:
I would appreciate if someone could help me
Thanks J?rg

<xsl:template match="OL1">
 <list class="alphanumerisch" align="left">
  <xsl:apply-templates select="LI[name(ancestor::*[1]) = 'OL1' ]" />
 </list>
</xsl:template>

<xsl:template match="OL2">
 <list class="alphanumerisch" align="left">
  <xsl:apply-templates select="LI [ name (ancestor::*[1] ) = 'OL2' ]" />
 </list>
</xsl:template>

<xsl:template match="LI [name(ancestor::*[1]) = 'OL1']">
<xsl:choose>

 <xsl:when test=" name(following-sibling::*[1]) = 'LI' ">
  <li class="standard_keine_Einrckung" align="left">
  <lidot>LI under OL1</lidot>
  <litext>
   <xsl:apply-templates/>
  </litext>
  </li>
 </xsl:when>

 <xsl:otherwise>
  <li class="standard_keine_Einrckung" align="left">
  <lidot>LI unterhalb von OL1</lidot>
  <litext>
   <xsl:value-of select=" node() " />

   <xsl:choose>
    <xsl:when test=" this point is the center of my question: What here has
to be tested to achieve the following? ">
     <xsl:apply-templates select=" following-sibling::OL2 [maybe
filter-expression here; in words: but not the one that follows a node"LI",
which is not the current node, to avoid recursion "/>  ]
    </xsl:when>
   </xsl:choose>

  </litext>
  </li>
 </xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template match="LI [name(ancestor::*[1]) = 'OL2']">
  <li class="standard_keine_Einrckung" align="left">
  <lidot>LI unterhalb von OL2</lidot>
  <litext>
   <xsl:apply-templates/>
  </litext>
  </li>
</xsl:template>

 
 
 

1. Need help with a simple XSLT/XPATH expression

Hi,

Could any 1 help me ? I need to write an Xpath statement to
(1) display all XML records which start with, for example the letter A.
(2) display all record that lie between two values. For example shows all
records that start with either A/B/C

I know this must be basic, but if some one could help me it would start me
off in the right direction.

Cheers
Dom.

2. Replacing SNA Gateways

3. Union expressions ( | symbol) allowed in schema selector XPATH expressions?

4. HELP WANTED: CAD DRAFTER

5. XPATH help with Expression

6. How do I: implement a missing DirectoryInfo/Directory method

7. XPath expression that runs a function on the attribute

8. MouseWheel Problem

9. Help with a Xpath expression.

10. evaluate a string as an XPath expression

11. xpath expression help

12. What's an XPath expression for the name of the root element?

13. Is there an XPath expression to get an element and a subset of its children?