xsl-list
[Top] [All Lists]

Re: XPath problem

2006-01-30 12:42:44
Hello,

Thank you very much for your replies. You helped a lot

Liron

----- Original Message ----- From: "Jay Bryant" <jay(_at_)bryantcs(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, January 30, 2006 7:00 PM
Subject: Re: [xsl] XPath problem


One XSLT 2.0 way:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:output method="xml" indent="yes"/>

 <xsl:template match="/">
   <out>
     <xsl:for-each select="root/test/para except root/test[2]/para[2]">
       <xsl:copy-of select="."/>
     </xsl:for-each>
   </out>
 </xsl:template>

</xsl:stylesheet>

One XSLT 1.0 way:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:output method="xml" indent="yes"/>

 <xsl:template match="/">
   <out>
     <xsl:for-each
select="root/test/para[not(count(../preceding-sibling::test) = 1 and
count(preceding-sibling::para) = 1)]">
       <xsl:copy-of select="."/>
     </xsl:for-each>
   </out>
 </xsl:template>

</xsl:stylesheet>

HTH

Jay Bryant
Bryant Communication Services


----- Original Message ----- From: "Liron" <magilam(_at_)netvision(_dot_)net(_dot_)il>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, January 30, 2006 10:24 AM
Subject: [xsl] XPath problem


Hello all,

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>

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 was
trying to write something like /root/test/para[position()!=2 and
ancestor::*[1][position()!=2]]/text() but it didn't work (I guess that
you're not surprised by that result...)
Is such a statement even possible in xpath? Also, how would I implement
such
a query on xslt?

(In my real document there could be more levels to avoid)

Thank you very much for your patience and help
Liron


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




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



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