Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 4th, 2007, 08:05 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Exclude Namespace Atribute

Hi,

This is probably a basic problem, but the answer escapes me. I am adding an element and some value to an existing xml file. When I run the following XSLT it adds xmlns="" to the element. How do i exclude this?

XSLT 2.0:

Code:
    <xsl:template match="ACM:Chapter">
        <xsl:copy>
            <xsl:choose>
                <xsl:when test="@*">
                    <xsl:copy-of select="@*"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:attribute name="id"><xsl:value-of select="generate-id()"/></xsl:attribute>
                </xsl:otherwise>
            </xsl:choose>
            <METADATA>
                <MMEL>
                    <xsl:attribute name="revdate"><xsl:text>2007-01-10</xsl:text></xsl:attribute>
                    <xsl:attribute name="mmelrev"><xsl:text>05</xsl:text></xsl:attribute>
                    <xsl:value-of select="//ACM:MELtitle"/>
                </MMEL>
            </METADATA>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>


Current output:

    <METADATA xmlns="">
            <MMEL revdate="2007-01-10" mmelrev="05">80-10-01</MMEL>
        </METADATA>



 
Old May 4th, 2007, 08:12 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You probably have a default namespace declared so it needs to be undeclared on this element. Show the rest of the stylsheet.

--

Joe (Microsoft MVP - XML)
 
Old May 4th, 2007, 08:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The system is adding xmlns="" because the METADATA element is in no namespace, but its parent is in a namespace. If you want the METADATA element to be in the same namespace as its parent then you must create it in that namespace, and the xmlns="" will automatically disappear.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 4th, 2007, 08:18 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Thanks,

I added the namespace declaration to the METADATA element. Works :)

You guys are the best. Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
css and style atribute equivalents nerssi Javascript 2 April 11th, 2007 05:26 AM
Document Function Atribute bonekrusher XSLT 2 September 26th, 2006 05:44 PM
Exclude Nodes seanhaggerty XSLT 1 February 3rd, 2005 06:00 AM
Exclude Certain Forms Ben Horne Access VBA 11 March 16th, 2004 03:06 PM
Exclude a field from refreshing Mimi Javascript How-To 2 August 25th, 2003 05:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.