[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

namespaces & xslt newbie question


xsl namespaces
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.