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

RE: Getting rid of xmlns="" attributes

Subject: RE: Getting rid of xmlns="" attributes
From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxx>
Date: Wed, 31 Dec 2003 13:15:03 -0000
xmlns attributes
> list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Allen, Erik
> Sent: 30 December 2003 23:23
> Subject:  Getting rid of xmlns="" attributes
 
> 	I've been using XSL for a few months now and I've been given a
> request for a transformation of our XML document into another XML
> document, with only some slight changes. One of the changes is to
remove
> a xml:space="preserve" attribute, but I consider that a trivial
problem
> that I can easily solve. (I'm just explicitly writing the element with
> the two other attributes that appear.) The bigger problem is that I
need
> to add two namespaces to the XML.
> 	From what I've read on this list, the best place to do something
> like that is to place the namespace definitions within the
> <xsl:stylesheet> element. I've done that, but now all the child
elements
> have xmlns="" appearing within them. My XSL looks like this:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
> 			xmlns="http://tempuri.org/FormSchema.xsd"
> 
> xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
> 			version = '1.0'>
> 
> <xsl:output method="xml"/>
> 
> <xsl:template match="/template">
> 	<template>
> 		<xsl:attribute name="version">
> 			<xsl:value-of select="@version"/>
> 		</xsl:attribute>
> 		<xsl:attribute name="readVersion">
> 			<xsl:value-of select="@readVersion"/>
> 		</xsl:attribute>
> 		<xsl:copy-of select="*"/>
> 	</template>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 	The transformation appears to work fine, except, as I said, the
> child elements of the root <template> element, all have the attribute
> xmlns="". A short snippet of it would be this:
 [Jim Fuller] 

should just have to add the following template to your xslt;

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

this is related to what is known as the identity transform; read up on
this here http://www.dpawson.co.uk/xsl/sect2/identity.html

also would be useful to always have an example xml, in addition to your
xslt, and which xslt processor you are using, there are some slight
differences (not incompability) when it comes to explicitly printing out
an xmlns attribute on every element which may affect your understanding.

Happy new year, Jim Fuller


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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