|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: matching attribute values with namespaces
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








