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

Removing empty namespace definition from an element

Subject: Removing empty namespace definition from an element
From: "Joel Friedman" <jfriedman@xxxxxxxxxxxx>
Date: Wed, 4 Aug 2004 11:34:05 -0400
empty namespace
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.