[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Temporary tree elements and namespaces: Further q
Richard,
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xhtml"> Since you are using XSLT 1.0, setting the default namespace (xmlns=http://www.w3.org/1999/xhtml) will affect literal result elements heading to the output document, so in this case any literal result element written to the output document will end up in the "http://www.w3.org/1999/xhtml" namespace by default. For pattern matching, expressions, etc., in the stylesheet, names with no prefix will still refer to the null namespace. So the following: <mappings> <relationship topic="1561.htm" toc="toc9497.htm" /> <relationship topic="950.htm" toc="toc.htm" /> . . </mappings> is correct -- all relationships will be selected because no prefix means no namespace, and as you indicated, map.map elements are in the null namespace. <xsl:value-of select="$mappings/relationship[@topic=@href]/@toc"> Even with Florent's correction: <xsl:value-of select="mappings[@topic eq @href]/@toc"/> I'm not sure what you're looking to do here since @href is not an attribute of anything in $mappings. However, you seem to indicate that @href is from another file perhaps, and is an attribute of an element that is in the http://www.w3.org/1999/xhtml namespace.... You can still handle that since you also defined the xhtml prefix to be bound to that namespace. Example: Assume map.map is the following XML document: <mappings> <relationship topic="1561.htm" toc="toc9497.htm"/> <relationship topic="950.htm" toc="toc.htm"/> </mappings> and assume Test.xml is the following XML document: <SomeElement xmlns="http://www.w3.org/1999/xhtml" href="1561.htm"/> Then the following XSLT (adapted from your snippets of code and includes Florent's correction): <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xhtml"> <xsl:variable name="mappings" select="document('map.map')/mappings/relationship" /> <xsl:variable name="xhtmlMappings" select="document('Test.xml')"/> <xsl:template match="mappings"> <LiteralResultElement> <xsl:value-of select="$mappings[@topic=$xhtmlMappings/xhtml:SomeElement/@href]/@toc"/> </LiteralResultElement> </xsl:template> </xsl:stylesheet> will output the following XML: <LiteralResultElement xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">toc9497.htm</LiteralResultElement> which you will note is an element in the http://www.w3.org/1999/xhtml namespace... Does that help? Cheers, ...sam
|
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
|