[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XPath problem

Subject: RE: XPath problem
From: cknell@xxxxxxxxxx
Date: Mon, 30 Jan 2006 11:58:59 -0500
RE:  XPath problem
> I'm trying to figure out how to build a xpath statement to get all the text 
> nodes besides from the 2nd <para> element of the 2nd <test> element. I
> Is such a statement even possible in xpath? 

Yes.

> Also, how would I implement such a query on xslt?

Here's a quick and dirty stylesheet. There are, undoubtedly, more elegant means.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*" />

    <xsl:template match="/">
      <xsl:apply-templates />
    </xsl:template>
  
  <xsl:template match="root">
    <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="test">
    <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="para[not(position()=2)]">
    <xsl:value-of select="." />
  </xsl:template>
  
  <xsl:template match="para[position()=2][parent::*[count(preceding-sibling::test)=1]]" />

</xsl:stylesheet>


-- 
Charles Knell
cknell@xxxxxxxxxx - email


> Assuming I have a document like this:

> <root>
>    <test>
>       <para>Text1</para>
>       <para>Text2</para>
>       <para>Text3</para>
>     </test>
>    <test>
>       <para>Text1</para>
>       <para>Text2</para>
>       <para>Text3</para>
>     </test>
>     <test>
>       <para>Text1</para>
>       <para>Text2</para>
>       <para>Text3</para>
>     </test>
> </root>

Current Thread
  • XPath problem
    • Liron - 30 Jan 2006 16:25:04 -0000
      • Jay Bryant - 30 Jan 2006 18:01:00 -0000
        • Liron - 30 Jan 2006 19:47:15 -0000
      • <Possible follow-ups>
      • cknell - 30 Jan 2006 16:59:26 -0000 <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.