|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Namespaces in XSL and how to access the elements
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
|
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








