Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Wed, 6 Aug 2008 00:33:44 -0700,    group: microsoft.public.xml        back       


Where are these pesky and superfluous xmlns="" coming from?   
Here is a fragment of my xml (input) file:

  <keys>
    <key-row id="kr1">
      <key position="1" row="1" id="esc" scan="110"> <outline x="249.9690" 
y="419.7360" width="34.2310" height="34.2180" /> </key>
      <key position="2" row="1" id="f1" scan="112"> <outline x="304.1550" 
y="419.7360" width="34.2310" height="34.2180"  /> </key>
      <key position="3" row="1" id="f2" scan="113"> <outline x="358.3410" 
y="419.7360" width="34.2310" height="34.2180"  /> </key>
    </key-row>
  </keys>

Here is a fragment of my xsl file:
  <xsl:template match="key">
     <Rectangle RadiusX="3" RadiusY="3" Stroke="#FFFF0000" 
StrokeMiterLimit="4" Canvas.Left="{outline/@x}" Canvas.Top="{outline/@y}" 
Width="{outline/@width}" Height="{outline/@height}"  StrokeThickness="1" 
ToolTip="row:{@row} position:{@position} id:{@id} scan:{@scan}" />
  </xsl:template>

Here is a fragment of the output:
<Rectangle RadiusX="3" RadiusY="3" Stroke="#FFFF0000" StrokeMiterLimit="4" 
Canvas.Left="249.9690" Canvas.Top="419.7360" Width="34.2310" 
Height="34.2180" StrokeThickness="1" ToolTip="row:1 position:1 id:esc 
scan:110" xmlns="" />

Where is this 'xmlns=""' coming from! How do I surpress it? It is screwing 
up my xaml and IE/silverlight does not like it! It happens with both xalan 
and System.Xml.Xsl;

Thanks!
Siegfried
date: Wed, 6 Aug 2008 00:33:44 -0700   author:   Siegfried Heintze

Re: Where are these pesky and superfluous xmlns="" coming from?   
Siegfried Heintze wrote:

> Here is a fragment of my xsl file:
>   <xsl:template match="key">
>      <Rectangle RadiusX="3" RadiusY="3" Stroke="#FFFF0000" 
> StrokeMiterLimit="4" Canvas.Left="{outline/@x}" Canvas.Top="{outline/@y}" 
> Width="{outline/@width}" Height="{outline/@height}"  StrokeThickness="1" 
> ToolTip="row:{@row} position:{@position} id:{@id} scan:{@scan}" />
>   </xsl:template>

That template creates an 'Rectangle' element in no namespace.

> Here is a fragment of the output:
> <Rectangle RadiusX="3" RadiusY="3" Stroke="#FFFF0000" StrokeMiterLimit="4" 
> Canvas.Left="249.9690" Canvas.Top="419.7360" Width="34.2310" 
> Height="34.2180" StrokeThickness="1" ToolTip="row:1 position:1 id:esc 
> scan:110" xmlns="" />
> 
> Where is this 'xmlns=""' coming from! 


You seem to insert that 'Rectangle' element into a parent element in a 
namespace and to ensure it has no namespace the serializer adds the 
xmlns="".

> How do I surpress it? 


You probably want
   <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0"
     xmlns="putNamespaceURIHere">
where you put the proper namespace URI you want for (all) your result 
elements in there.

Or you need to use

   <xsl:template match="key">
      <Rectangle xmlns="putNamespaceURIHere" RadiusX="3" RadiusY="3" 
Stroke="#FFFF0000"
StrokeMiterLimit="4" Canvas.Left="{outline/@x}" Canvas.Top="{outline/@y}"
Width="{outline/@width}" Height="{outline/@height}"  StrokeThickness="1"
ToolTip="row:{@row} position:{@position} id:{@id} scan:{@scan}" />
   </xsl:template>


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Wed, 06 Aug 2008 13:21:26 +0200   author:   Martin Honnen

Re: Where are these pesky and superfluous xmlns="" coming from?   
That fixed it! Why is this only a problem with Rectangles? I emit labels and 
paths without this problem.
Thanks!
Siegfried
date: Wed, 6 Aug 2008 08:12:32 -0700   author:   Siegfried Heintze

Re: Where are these pesky and superfluous xmlns="" coming from?   
Siegfried Heintze wrote:
> That fixed it! Why is this only a problem with Rectangles? I emit labels and 
> paths without this problem.

It is certainly not a problem of 'Rectangle' elements, it is rather a 
question on how you organize your stylesheet and its namespace 
declarations. If you do e.g.

   <xsl:template match="/">
      <Window xmlns="http://example.com/">
        <Label/>
        <Path/>
        <xsl:apply-templates/>
      </Window>
   </xsl:template>

   <xsl:template match="key">
      <Rectangle/>
   </xsl:template>

then the Window element and its children, the Label and the Path element 
have the namespace declaration in scope while the Rectangle element in 
the other template does not have it.

That is just a guess on how your stylesheet structure might look, you 
did not share much of your stylesheet so I can't give a more specific 
explanation.



-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Wed, 06 Aug 2008 17:56:27 +0200   author:   Martin Honnen

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us