OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   namespaces & xslt newbie question

[ Lists Home | Date Index | Thread Index ]

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>
=======================================





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS