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

RE: Removing empty namespace definition from an elemen

Subject: RE: Removing empty namespace definition from an element
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 5 Aug 2004 08:50:45 +0100
empty namespace
The basic message with problems like this is to make sure that your elements
are in the right namespace; if they are, the namespace declarations will
look after themselves. You have the unwanted namespace declaration because
you created the element in the wrong namespace.

If you use xsl:element to create an element, use the namespace attribute to
define what namespace you want it to be in. But in this case, you could
equally well use a literal result element.

Michael Kay  

> -----Original Message-----
> From: Joel Friedman [mailto:jfriedman@xxxxxxxxxxxx] 
> Sent: 04 August 2004 16:34
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Removing empty namespace definition from an element
> 
> I've learned quite a lot since my last post.  I've managed to 
> rework my
> XSL file in accordance with Mike Kay's suggestions.  I only have one
> obstacle left in my transformation.
> 
> Here is the beginning of my input XML:
> 
> <?xml version="1.0" encoding="utf-16"?>
> <sequence version="1" description="Deploy Server"
> command="DeployServer.xml"
> xmlns="http://schemas.microsoft.com/ads/2003/sequence">
>   <task description="Launch Image Deployment Tool" doesReboot="false">
>     <command target="controller">C:\Patches\Tools\dpIDT.vbs</command>
>     <parameters>
>       <parameter>$device.system.name$</parameter>
>       <parameter>_osName_</parameter>
>     </parameters>
>   </task>
> 
> 
> And here is part of the relevant XSL:
> 
> xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  
> xmlns:ads="http://schemas.microsoft.com/ads/2003/sequence"
>                 version="1.0">
> 
>   <xsl:output method="xml" indent="yes"/>
>   <xsl:variable name="osName" select="'WIN2K3'"/>
> 
>   <xsl:template match="/">
>     <xsl:apply-templates/>
>   </xsl:template>
> 
>   <xsl:template match="ads:parameter[.='_osName_']">
>     <xsl:element name="parameter"><xsl:value-of
> select="$osName"/></xsl:element>
>   </xsl:template>
> 
> 
> Now the match works just fine, the issue is the element 
> parameter looks
> like this in the output:
> 
> <task description="Launch Image Deployment Tool" doesReboot="false">
> <command target="controller">C:\Patches\Tools\dpIDT.vbs</command>
> <parameters>
> <parameter>$device.system.name$</parameter>
> <parameter xmlns="">WIN2K3</parameter>
> </parameters>
> </task>
> 
> My interpreter does not like the empty namespace declaration. 
>  The only
> way I have figured out how to get it to not show is by using this as a
> template instead:
> 
>   <xsl:template match="ads:parameter[.='_osName_']">
>     <xsl:text 
> disable-output-escaping="yes">&lt;parameter&gt;</xsl:text>
>         <xsl:value-of select="$osName"/>
>     <xsl:text
> disable-output-escaping="yes">&lt;/parameter&gt;</xsl:text>
>   </xsl:template>
> 
> 
> And that's REAL UGLY!
> 
> 
> Is there a better?  A real way, using XSLT logic?

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.