Subject: Re: [xsl] matching attribute values with namespaces From: "Christopher R. Maden" <crism@xxxxxxxxx> Date: Tue, 12 Jul 2005 14:02:33 -0700 (PDT) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] matching attribute values wit, Stefan Podkowinski | Thread | Re: [xsl] matching attribute values, David Carlisle |
Re: [xsl] grouping by x number of e, David Carlisle | Date | Re: [xsl] matching attribute values, David Carlisle |
Month |