[xsl] preceding-sibling question

Subject: [xsl] preceding-sibling question
From: <ming.tan@xxxxxxxxxxx>
Date: Thu, 16 Mar 2006 18:04:46 -0600
Hi, all:

Here's the sample XML that I am working on:

<n-docbody>
  <update.link.block>
   <link.parameter>
    <parameter.name>COUNTY</parameter.name>
    <parameter.value>ABC</parameter.value>
   </link.parameter>
   <link.parameter>
    <parameter.name>CN</parameter.name>
    <parameter.value>123456789</parameter.value>
   </link.parameter>
  </update.link.block>
</n-docbody>

As you can see there are two pairs of parameter.name and parameter.value
elements in my XML, and these are the templates I am using:

  <xsl:template match="/">
         <xsl:element name="listitem">
                            <xsl:apply-templates
select="n-docbody/update.link.block/link.parameter/parameter.value" />
         </xsl:element>
  </xsl:template>

# to generate the county element
 <xsl:template match="parameter.value">
     <xsl:element name="county">
      <xsl:attribute name="linkparam">true</xsl:attribute>
      <xsl:apply-templates/>
     </xsl:element>
  </xsl:template>

The result, I have multiple county elements generated:

<?xml version="1.0" encoding="iso-8859-1"?>
<listitem>
 <casenumber linkparam="true">L00031406</casenumber>
 <casename>BLANCHE LAKS v. STRATHALLAN AT JACKSON LLC</casename>
 <pretty-name>N.J.SUPER.</pretty-name>
 <county linkparam="true">OCN</county>
 <county linkparam="true">L-000314-06</county>
 <filed>01/18/2006</filed>
</listitem>


How do I using preceding-sibling axis to only generate the county
element when and preceding sibling (the parameter.name element) has the
value of "COUNTY"?

Thanks in advance.

Ming Tan

Current Thread