[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] namespaces & xslt newbie question
Hello, I'm new to XSLT and I encounter problems with the use of namespaces I wish to transform my documents with msxsl (msxml wrapper), I use windows 2000 and msxml 4.0 SP1 My input file use a namespace for his root element (xmlns="documenttype1") and the transformation doesn't perform if I don't remove the namespace (else the <xsl:template> from the xsl doesn't apply) If anyone could give a hand, I'm begining with namespace in xsl Thanks alot Gauthier INPUT: ======================================= <?xml version="1.0" encoding="ISO-8859-1"?> <root xmlns="documenttype1"> <elm1>Value1</elm1> </root> ======================================= STYLESHEET: ======================================= <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="ISO-8859-1" version="1.0" omit-xml-declaration="no" indent="yes"/> <!-- match la racine --> <xsl:template match="/"> <xsl:element namespace="documenttype2" name="page"> <xsl:apply-templates select="/root/*"/> </xsl:element> </xsl:template> <!-- match tout les fils de root --> <xsl:template match="/root/*"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> ======================================= OUTPUT with namespace in the source xml root element ======================================= <?xml version="1.0" encoding="ISO-8859-1"?> <page xmlns="documenttype2"></page> ======================================= OUTPUT without namespace in the source xml root element ======================================= <?xml version="1.0" encoding="ISO-8859-1"?> <page xmlns="documenttype2"> <elm1 xmlns="">Value1</elm1> </page> ======================================= Desired OUTPUT ======================================= <?xml version="1.0" encoding="ISO-8859-1"?> <page xmlns="documenttype2"> <elm1>Value1</elm1> </page> =======================================
|
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
|