Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2004, 08:15 PM
Authorized User
 
Join Date: Jan 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Whats the diff??

child::node() <--selects all the children of the current node

child::* <--- selects all the child elements of the current node


Aren't they the same? if not, then whats the diff??

-Nikolas

 
Old January 12th, 2004, 06:23 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

* selects all nodes of the principal node type for the relevant axis. What this means in English is that unless you are using the attribute axis or the namespace axis you will get elements. Not all nodes are elements, attributes for instance.
[code]
<ingredients>
  <item type="fruit">apples</item>
  <item type="basic">flour</item>
  <item type="basic">sugar</item>
  <item type="dairy">milk</item>
  <item type="basic">salt</item>
  <item type="dairy">butter</item>
</ingredients>
[code]
With the above source try this xslt:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:text>#x0a;</xsl:text>
    select="ingredients/*":<xsl:text>#x0a;</xsl:text><xsl:text>#x0a;</xsl:text>
    <xsl:for-each select="ingredients/*">
       <xsl:value-of select="."/><xsl:text>#x0a;</xsl:text>
    </xsl:for-each>

    select="ingredients/attribute::*":<xsl:text>#x0a;</xsl:text><xsl:text>#x0a;</xsl:text>
    <xsl:for-each select="ingredients/item/attribute::*">
      <xsl:value-of select="."/><xsl:text>#x0a;</xsl:text>
    </xsl:for-each>

    select="ingredients/item/node()":<xsl:text>#x0a;</xsl:text><xsl:text>#x0a;</xsl:text>
    <xsl:for-each select="ingredients/item/node()">
      <xsl:value-of select="."/><xsl:text>#x0a;</xsl:text>
    </xsl:for-each>

    select="ingredients/node()":<xsl:text>#x0a;</xsl:text><xsl:text>#x0a;</xsl:text>
    <xsl:for-each select="ingredients/node()">
       <xsl:value-of select="."/><xsl:text>#x0a;</xsl:text>
    </xsl:for-each>

    select="ingredients/attribute::node()":<xsl:text>#x0a;</xsl:text><xsl:text>#x0a;</xsl:text>
    <xsl:for-each select="ingredients/item/attribute::node()">
       <xsl:value-of select="."/><xsl:text>#x0a;</xsl:text>
    </xsl:for-each>     
  </xsl:template>

</xsl:stylesheet>
Joe (MVP - xml)
 
Old January 17th, 2004, 07:11 PM
Authorized User
 
Join Date: Jan 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx mate!.. i think i got it.

-Nikolas






Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats the work around? aaronmuslim XSLT 5 March 26th, 2008 04:10 PM
Whats this book like? PaulBerry BOOK: Beginning C# 2005 Databases 0 January 25th, 2008 12:55 PM
Whats up with the forums?? dparsons Forum and Wrox.com Feedback 6 May 18th, 2007 11:42 AM
Codegroup Whats it? JelfMaria VS.NET 2002/2003 3 July 8th, 2005 09:43 AM
Whats wrong? Agentofnight Beginning PHP 3 April 17th, 2005 04:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.