xsl-list
[Top] [All Lists]

[xsl] preceding-sibling question

2006-03-16 17:05:03
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

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

<Prev in Thread] Current Thread [Next in Thread>