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

Re: Extracting element names for output

Subject: Re: Extracting element names for output
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Jun 1999 19:24:45 -0700
extracting node name in xslt
At 99/06/18 20:04 -0400, Vernon_Imrich@xxxxxxxxxxxxxx wrote:
>Is there any support in XSL for extracting the NAME of the XML element (or
node)
>as the generated text rather than the value of the node? (For that matter,
how
>about extracting the names of all the element attributes; again, rather
than the
>value of the element attributes?)

The name of the node (be it an element node, attribute node, processing
instruction) can be accessed in a number of ways for different uses.  An
example below should illustrate everything you need.

I hope this helps.

......... Ken


T:\imrich>type test.xml
<?xml version="1.0"?>
<test xmlns:crane="http://www.CraneSoftwrights.com/s/">
  <crane:test1 attr1="attr">
    <!--a comment-->
    <test2 crane:attr2="attr"/>
  </crane:test1>
  <?pitest here?>
</test>
T:\imrich>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

<xsl:template match="/">
  <xsl:for-each select="//*|//@*|//pi()">

qname(.):      <xsl:value-of select="qname(.)"/>
local-part(.): <xsl:value-of select="local-part(.)"/>
prefix:        <xsl:value-of select="substring-before( qname(.), ':' )"/>
namespace(.):  <xsl:value-of select="namespace(.)"/>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

T:\imrich>call xsl test.xml test.xsl test.htm
T:\imrich>type test.htm


qname(.):      test
local-part(.): test
prefix:        
namespace(.):  

qname(.):      crane:test1
local-part(.): test1
prefix:        crane
namespace(.):  http://www.CraneSoftwrights.com/s/

qname(.):      attr1
local-part(.): attr1
prefix:        
namespace(.):  

qname(.):      test2
local-part(.): test2
prefix:        
namespace(.):  

qname(.):      crane:attr2
local-part(.): attr2
prefix:        crane
namespace(.):  http://www.CraneSoftwrights.com/s/

qname(.):      pitest
local-part(.): pitest
prefix:        
namespace(.):  
T:\imrich>

--
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Publications:   Introduction to XSLT (3rd Edition) ISBN 1-894049-00-4


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.