Subject: [xsl] Namespaces in XSL and how to access the elements From: "Rob Sutherland" <rob@xxxxxxxxxxxxxxxxx> Date: Wed, 26 Feb 2003 15:23:49 -0800 |
Hello all: I am trying to get my brain around Namespaces in XSL. I think the example below will make clear what i am struggling with. XML file <<< <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> ... <item rdf:about="url-here"> <title>Title would go here</title> ... </item> ... </rdf:RDF> >>> I want to get to the <item> elements whose parent is the <rdf:RDF> element. I can get to the <rdf:RDF> element by using the following. <xsl:stylesheet version="1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="rdf" > <xsl:template match="rdf:RDF"> Now, what i thought would work to select the <item> elements now that I am in the proper context would be the following. <xsl:for-each select="item"> <xsl:value-of select="title" /><br /> </xsl:for-each> But this doesn't work. I get no output. So I went about it another way and came up with this: <xsl:for-each select="./*[name(.) = 'item']"> <xsl:value-of select="./*[name(.) = 'title']" /><br /> </xsl:for-each> Now this works, but seems cumbersome and not as effecient/quick as it could be. So i have something that works, but i want to know if there is a better/more correct way to do this. If not okay, then i have what i am looking for, but i just wanted some advice from somebody with more XSL experience. Rob Sutherland XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] open and closed tag merge, Martinez, Brian | Thread | Re: [xsl] Namespaces in XSL and how, Mike Brown |
Re: [xsl] open and closed tag merge, David Smith | Date | RE: [xsl] XSL-FO versus PostScript, Roger Glover |
Month |