[xslt] Question of "xsltproc" result



Hello,
I'm working on a project about XSLT.  I was told that the performance of "libxslt" is quite ( very ) good compared with some other packages.
So, I started my testing with "libxslt" ( libxslt-0.5.0 and libxml2-2.3.4 ) and here I met a problem which can be demo with following XML and XSL.
In the testing XSL, I want to select all 2nd "MEMBER" of "GROUP" ( except the 1st GROUP ).
---------------------------------------------------------------------------------------
My XSL is :-
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
      <xsl:apply-templates select="ROOT"/>
</xsl:template>
<xsl:template match="ROOT">
      <xsl:for-each select="GROUP[position() != 1]/MEMBER[2]">
            <xsl:copy-of select="."/>
      </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------------------------
XML content :-
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
  <GROUP name="G1">
    <MEMBER name="M1">
      <CONTENT>MEMBER 1 of GROUP 1</CONTENT>
    </MEMBER>
    <MEMBER name="M2">
      <CONTENT>MEMBER 2 of GROUP 1</CONTENT>
    </MEMBER>
    <MEMBER name="M3">
      <CONTENT>MEMBER 3 of GROUP 1</CONTENT>
    </MEMBER>
  </GROUP>

  <GROUP name="G2">
    <MEMBER name="M1">
      <CONTENT>MEMBER 1 of GROUP 2</CONTENT>
    </MEMBER>
    <MEMBER name="M2">
      <CONTENT>MEMBER 2 of GROUP 2</CONTENT>
    </MEMBER>
    <MEMBER name="M3">
      <CONTENT>MEMBER 3 of GROUP 2</CONTENT>
    </MEMBER>
  </GROUP>

  <GROUP name="G3">
    <MEMBER name="M1">
      <CONTENT>MEMBER 1 of GROUP 3</CONTENT>
    </MEMBER>
    <MEMBER name="M2">
      <CONTENT>MEMBER 2 of GROUP 3</CONTENT>
    </MEMBER>
    <MEMBER name="M3">
      <CONTENT>MEMBER 3 of GROUP 3</CONTENT>
    </MEMBER>
  </GROUP>
</ROOT>
----------------------------------------------------------------------------------------
And my expected result should be something like :-
<MEMBER name="M2">
   <CONTENT>MEMBER 2 of GROUP 2</CONTENT>
</MEMBER>
<MEMBER name="M2">
   <CONTENT>MEMBER 2 of GROUP 3</CONTENT>
</MEMBER>
---------------------------------------------------------------------------------------
But what I got from "xsltproc" is :-
<MEMBER name="M2">
      <CONTENT>MEMBER 2 of GROUP 2</CONTENT>
</MEMBER>
==========================================================

PC Chow
ABC QuickSilver
Hong Kong
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]