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 November 18th, 2009, 10:32 AM
Authorized User
 
Join Date: Oct 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default xmlns attribute

Hi All,

I m created style sheet in that i am executing SVg code to draw rectangle and output some code. But the problem is when it is generating XML for the Output in Oxygen editor its adding xmlns="" attribute in all the svg tag.

below is the code for XSLT and output XML

XSLT :

Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:template match="/">
<xsl:call-template name="go_to_next_state">
            <xsl:with-param name="tape" select="$tape"/>
</xsl:call-template>

<xsl:template name="go_to_next_state">
    <xsl:param name="step_number"/> <!-- Increment for each state transition.-->

    <xsl:param name="tape"/> 

    <rect x="20" y="20" width="30" height="30"
        style="fill:blue;stroke:pink;stroke-width:5;
        fill-opacity:0.1;stroke-opacity:0.9"/>
    <text x="30" y="20" style="font-family:arial;text-anchor:middle;baseline-shift:-15;">
        
        <xsl:value-of select="$tape"/>
    </text>

</xsl:template>
Output XML

<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><rect xmlns="" x="20" y="20" width="30" height="30" style="fill:blue;stroke:pink;stroke-width:5; fill-opacity:0.1;stroke-opacity:0.9"/><text xmlns="" x="30" y="20" style="font-family:arial;text-anchor:middle;baseline-shift:-15;">123</text>
</svg>


In the above output xml its adding xmlns="" in every svg tag.

Can you please tell me how to avoid that and why its coming.

Thanks

Hari
 
Old November 18th, 2009, 10:37 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You have defined the <svg> element to be in the SVG namespace, but you have defined everything else to be in the default namespace, which is the blank namespace.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 18th, 2009, 11:39 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you want all literal result elements to be in the SVG namespace then you can simply put the namespace definition on the xsl:stylesheet element e.g.
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/2000/svg"
  version="1.0">

  ...

</xsl:stylesheet>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
xmlns as an attribute Neal XSLT 7 February 16th, 2009 10:38 AM
XMLNS mathias XML 0 February 20th, 2007 04:46 AM
Soap Error : Attribute xmlns must be declared RatanKumar XML 0 December 4th, 2006 08:07 PM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
attribute xmlns added in included xsl Kabe XSLT 6 November 23rd, 2004 12:24 PM





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