|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: conditional namespaces
I want to thank you all for your helpfull replies. I know I didn't declare
the namespace and the prefix, and that this would be a problem.
Both were variables , the prefix I get as a parameter, and the namespace uri is the result of of concat. Maybe a bit weird, but it is exactly what we needed. I solved it with the help of your comments , and I want to share the xsl I came up with. Just so anyone who followed this thread is able to look at the result, and maybe give some comments on it :-) Here we go: XML: <document> <title>google</title> <a>aaa</a> </document> XSLT: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="attribute">type</xsl:param> <xsl:param name="value">gg</xsl:param> <xsl:param name="namespace-prefix">ns</xsl:param> <xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template><xsl:template match="document"> <xsl:variable name="namespace" select="concat('http://www.',title,'.com')"/> <document> <xsl:attribute name="{concat($namespace-prefix,':',$attribute)}" namespace="{$namespace}"> <xsl:value-of select="$value" /> </xsl:attribute> <xsl:apply-templates/> <xsl:comment> Namespace-prexix: <xsl:value-of select="$namespace-prefix"/> Namespace URI : <xsl:value-of select="$namespace"/> </xsl:comment> </document> </xsl:template> </xsl:stylesheet> Once again thank you Jeni, Trever and Mike RH 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








