How to remove xmlns="http://tempuri.org/???.xsd" RRS feed

  • Question

  • User-845515816 posted
    When I call the method WriteXML of my DataSet, the root element get this attribute: xmlns="http://tempuri.org/NameOfTheElement.xsd" and it's messing up my XSLT. Is there a way to tell .Net not to write this attribute ? Exemple <?xml version="1.0" standalone="yes"?> <Specials xmlns="http://tempuri.org/Specials.xsd"> <Trip> <ID>0</ID> <Lieux>Québec</Lieux> <Hotel>Manoir</Hotel> <Depart>1 mars</Depart> <Duree>3 jours</Duree> <Prix>150</Prix> <ToutCompris>true</ToutCompris> <Rating>3.5</Rating> <Description>Le manoir</Description> </Trip> </Specials>
    Thursday, January 29, 2004 10:27 AM

All replies

  • User2032526919 posted
    Hi, it seems to be coded into the DataSet such that you can't avoid it. However, DataSet has Namespace and Prefix properties that let you tweak the namespace and aliasing prefix respectively. And you can get over the "messing" by declaring in the XSLT a namespace with the same namespace URI as the namespace of DataSet and give it a self-chosen prefix. Then you can refer to DataSet's elements in the XSLT using this namespace's prefix (even if DataSet has default namespace applied, you can refer to elements by having a namespace declaration with the same URI in the XSLT) So if you have namespace: ... <Specials xmlns="http://tempuri.org/Specials.xsd"> ... You can refer this in XSLT like: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:prfx="http://tempuri.org/Specials.xsd"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="prfx:Specials"/> </xsl:template> <xsl:template match="prfx:Specials"> Match Specials node </xsl:template> </xsl:stylesheet>
    Saturday, January 31, 2004 2:36 AM
  • User-845515816 posted
    Thanks that worked, the only problem was that every time I output a tag from the XSLT, the tag came with the specified namespace. I was able to remove the namespace by removing the targetNamespace attribute of <xsd:schema> of my dataSet Schema. Thanks for your help
    Wednesday, February 4, 2004 9:18 AM
  • User2032526919 posted
    Hi, you can prevent a namespace declaration from being outputted by using exclude-result-prefixes element in <xsl:stylesheet> element. See documentation about it here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xsl_elm_qz_0cfo.asp (This does not mean XSL Transformations in .NET would use MSXML, but the documentation generally is ok to provide information and .NET XSL works pretty much the same)
    Wednesday, February 4, 2004 3:00 PM
  • User967082414 posted

    This was perfect for me!

    Thursday, June 2, 2016 11:22 PM