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

Re: Hot to get names ??

Subject: Re: Hot to get names ??
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Tue, 26 Feb 2002 12:39:27 -0800
get names
Why not something like:

<xsl:template match="product/*[starts-with(local-name(), 'udt')]">
  UDT Value: <xsl:value-of select="."/>
</xsl:template>

Or

<xsl:template match="product">
  Some stuff.
  <xsl:apply-templates select="*[starts-with(local-name(), 'udt')]"/>
  Some more stuff.
</xsl:template>


Alternatively, if you just wanted to get elements between last-modified and 
start-date regardless of whether they actually have names that start with 
'udt', you could replace the appropriate part of the XPath expression with 
something like this:

*[preceding-sibling::last-modified and following-sibling::start-date]


I used local-name() instead of name() since if your elements have a namespace 
and prefix, then the prefix would likely screw up the test, but it shouldn't 
matter if used with the example you gave.

On Tuesday 26 February 2002 10:39, Khalid wrote:
> Hello All,
> How do I get the names of each element and then do some processing
> accordingly,I can't seem to find a way to use name() appropriately,any help
> is appreciated,
>
> below is the chunk of xml that I am using,I want to be  able to get all the
> elements which are after last-modified and before start-date,so I would
> like to get some condition that checks for the elements names that begin
> with 'udt',but there are other elements attached to this element and the
> have the same structure,and what I want is only get the values at each
> level from between the last-modified and start-date.
>
> <product>
>     <system-id>4</system-id>
>     <last-modified>22 January, 2002 09:26</last-modified>
>     <udt-product-id>DMD</udt-product-id>
>     <udt-product-name>Daily Mail Monday to Friday</udt-product-name>
>     <start-date>7 January, 2002</start-date>
>     <end-date />
>     <publishing-frequency>Weekly</publishing-frequency>
>     <editions>
>       <edition>
>         <system-id>71</system-id>
>         <last-modified>22 January, 2002 09:21</last-modified>
>         <udt-product-code>DMD</udt-product-code>
>         <udt-edition-name>Anglia1</udt-edition-name>
>         <udt-print-centre-code>HQP</udt-print-centre-code>
>         <udt-descriptor>Edition</udt-descriptor>
>         <start-date>8 January, 2002</start-date>
>         <end-date />
>
> </editions>
> </produict>
> </products>
> in the above example the tree contains multiple subroot elements that has
> the same structure as product.I need to get only the elements which start
> with udt at each level.,say first I would like to get all the elements that
> start-with 'udt' from the product level,at this point I do not want to get
> any element which may appear at lower level of heirarchy such as editions.I
> would only want edition related values on descretion.
> please guide,thanks
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
Peter Davis
I can read your mind, and you should be ashamed of yourself.

 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.