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

Re: matching attribute values with namespaces

Subject: Re: matching attribute values with namespaces
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Tue, 12 Jul 2005 14:02:33 -0700 (PDT)
xsl matching attribute values
Stefan Podkowinski wrote:
> I'm currently having a hard time to create a xsl definition for the
> following situation:
>
> <document
>    xmlns:providerns1="http://somewhere.com/"
>    xmlns:providerns2="http://sometimes.com/">
> <entry type="providerns1:header">test</entry>
> <entry type="providerns1:paragraph">test</entry>
> <entry type="providerns2:paragraph">test</entry>
> <entry type="providerns2:footer">test</entry>
> </document>
>
> What I basically need to do is to check to which namespace each "type"
> attribute value belongs to. Afterwards I'm able to go on to transform
> the entry element depending on the type value for the determinated
> namespace.

Check out '5.4 of XPath 1.0.  A namespace nodes name is its prefix, and
its value is the URI.

<xsl:template match="document">
  <!-- This will be the providerns1 namespace node. -->
  <xsl:variable name="ns1"
    select="namespace::*[. = 'http://somewhere.com/']"/>
  <xsl:apply-templates
    select="entry[contains(@type, name($ns1))]"/>
</xsl:template>

That template should process only the entry elements whose type contains
the prefix bound to http://somewhere.com/.  (The contains() expression
should actually be more complex than that to avoid inadvertent substring
matches.)

That also wont work if the entry elements themselves define any relevant
namespaces themselves.  So dont do that. (-:

~Chris
-- 
Christopher R. Maden, Principal Consultant, crism consulting
XML-SGML-HTML-DTDs-schemas-XSL-DSSSL-conversion-training-ebooks-B2B
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA

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.