xsl-list
[Top] [All Lists]

Re: [xsl] XPath equivalence question

2011-12-01 03:43:41
Have you tried out what you propose as equivalent below?

No XSLT processor is doing what you say, xsltproc, saxon, DataPower, ...

$ saxon Graydon.1.xsl Graydon.xml ; echo
<?xml version="1.0" encoding="UTF-8"?><B/>
$
$ saxon Graydon.2.xsl Graydon.xml ; echo
<?xml version="1.0" encoding="UTF-8"?>
$
$ cat Graydon.xml
<A><a><b><c><B/></c></b></a></A>
$
$ cat Graydon.1.xsl
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

  <xsl:output method="xml"/>

  <xsl:template match="/">
    <xsl:copy-of select="/A//B"/>
  </xsl:template>

</xsl:stylesheet>
$
$ cat Graydon.2.xsl
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

  <xsl:output method="xml"/>

  <xsl:template match="/">
    <xsl:copy-of select="B[/A]"/>
  </xsl:template>

</xsl:stylesheet>
$


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team, Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


                                                                                
                                                        
  From:       Graydon <graydon(_at_)marost(_dot_)ca>                            
                                                                   
                                                                                
                                                        
  To:         xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com,                 
                                                                         
                                                                                
                                                        
  Date:       12/01/2011 12:50 AM                                               
                                                        
                                                                                
                                                        
  Subject:    [xsl] XPath equivalence question                                  
                                                        
                                                                                
                                                        
  Sent by:    <graydon(_at_)marost(_dot_)ca>                                    
                                                                   
                                                                                
                                                        





Does

<xsl:template match="/A//B">

match exactly the same thing as

<xsl:template match="B[/A]">?

My presumption is that the second form is preferable on efficiency
grounds -- on simple table lookup versus whatever tree-structure the
descendant axis search produces -- but I don't actually know.

-- Graydon

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