Home All Groups Group Topic Archive Search About

Dataset.GetXml incorrectly renders XMLNS tag, breaks XSLT

Author
24 Oct 2006 2:01 PM
Bill Sempf
I have a very simple dataset, just 4 fields in one table.  I am using the
GetXml method of the dataset to render the XML into an XmlStream, and then
XmlCompiledTransform to implement an XSLT, then save it to an HTML file.

The Dataset.GetXml method oncorrectly renders the xmlns for my dataset,
though.  Since it is a strongly typed dataset, the XSD is added to the root
node, as such:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='ProblemStoreReport.xsl'?>
<ProblemStores xmlns="http://tempuri.org/ProblemStores.xsd">
  <ProblemStore>
    <SiteNumber>00260</SiteNumber>
    <SiteName>00260 - 632 3RD AVE.</SiteName>
    <Variance>Daily Sales Number is Missing</Variance>
    <Problem>This store has a communications problem</Problem>
  </ProblemStore>
  <ProblemStore>
    <SiteNumber>01209</SiteNumber>
    <SiteName>01209 - COUNTY LINe QUEBEC</SiteName>
    <Variance>No data at all</Variance>
    <Problem>This store has a communications problem</Problem>
  </ProblemStore>
  <ProblemStore>
    <SiteNumber>01598</SiteNumber>
    <SiteName>01598 - W. BANK EXPRESSWAY</SiteName>
    <Variance>No data at all</Variance>
    <Problem>This store has a communications problem</Problem>
  </ProblemStore>
</ProblemStores>

The third line should be:

<ProblemStores xmlns:xsd="http://tempuri.org/ProblemStores.xsd">

Why do I care?  If you transform it with the first version - the incorrectly
rendered version - the XSD won't find the first node.  If you transform it
with the :xsd added, it renders fine.

Is there a workaround?

Thanks.

S

Author
24 Oct 2006 4:26 PM
Mark Nelson
Bill,

There is a class called XmlNameSpaceManager in System.Xml namespace.
This helps you to play around with the namespaces

Pls check whether this link helps you
http://msdn2.microsoft.com/en-us/library/d6730bwt.aspx

--
Thanks & Regards,
Mark Nelson


Show quote
"Bill Sempf" wrote:

> I have a very simple dataset, just 4 fields in one table.  I am using the
> GetXml method of the dataset to render the XML into an XmlStream, and then
> XmlCompiledTransform to implement an XSLT, then save it to an HTML file.
>
> The Dataset.GetXml method oncorrectly renders the xmlns for my dataset,
> though.  Since it is a strongly typed dataset, the XSD is added to the root
> node, as such:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type='text/xsl' href='ProblemStoreReport.xsl'?>
> <ProblemStores xmlns="http://tempuri.org/ProblemStores.xsd">
>   <ProblemStore>
>     <SiteNumber>00260</SiteNumber>
>     <SiteName>00260 - 632 3RD AVE.</SiteName>
>     <Variance>Daily Sales Number is Missing</Variance>
>     <Problem>This store has a communications problem</Problem>
>   </ProblemStore>
>   <ProblemStore>
>     <SiteNumber>01209</SiteNumber>
>     <SiteName>01209 - COUNTY LINe QUEBEC</SiteName>
>     <Variance>No data at all</Variance>
>     <Problem>This store has a communications problem</Problem>
>   </ProblemStore>
>   <ProblemStore>
>     <SiteNumber>01598</SiteNumber>
>     <SiteName>01598 - W. BANK EXPRESSWAY</SiteName>
>     <Variance>No data at all</Variance>
>     <Problem>This store has a communications problem</Problem>
>   </ProblemStore>
> </ProblemStores>
>
> The third line should be:
>
> <ProblemStores xmlns:xsd="http://tempuri.org/ProblemStores.xsd">
>
> Why do I care?  If you transform it with the first version - the incorrectly
> rendered version - the XSD won't find the first node.  If you transform it
> with the :xsd added, it renders fine.
>
> Is there a workaround?
>
> Thanks.
>
> S
>
>
Author
25 Oct 2006 3:18 PM
Bill Sempf
Close but no cigar.  The XmlNameSpaceManager thinks that the namespace is
"http://www.w3.org/2000/xmlns/" - I think it doesn't handle exactly what I
want to do.  I think it wants to take attributesout of the XML node at the
top, and I need the DTD attribute taken out of the main table.

Show quote
"Mark Nelson" wrote:

> Bill,
>
> There is a class called XmlNameSpaceManager in System.Xml namespace.
> This helps you to play around with the namespaces
>
> Pls check whether this link helps you
> http://msdn2.microsoft.com/en-us/library/d6730bwt.aspx
>
> --
> Thanks & Regards,
> Mark Nelson
>
>
> "Bill Sempf" wrote:
>
> > I have a very simple dataset, just 4 fields in one table.  I am using the
> > GetXml method of the dataset to render the XML into an XmlStream, and then
> > XmlCompiledTransform to implement an XSLT, then save it to an HTML file.
> >
> > The Dataset.GetXml method oncorrectly renders the xmlns for my dataset,
> > though.  Since it is a strongly typed dataset, the XSD is added to the root
> > node, as such:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <?xml-stylesheet type='text/xsl' href='ProblemStoreReport.xsl'?>
> > <ProblemStores xmlns="http://tempuri.org/ProblemStores.xsd">
> >   <ProblemStore>
> >     <SiteNumber>00260</SiteNumber>
> >     <SiteName>00260 - 632 3RD AVE.</SiteName>
> >     <Variance>Daily Sales Number is Missing</Variance>
> >     <Problem>This store has a communications problem</Problem>
> >   </ProblemStore>
> >   <ProblemStore>
> >     <SiteNumber>01209</SiteNumber>
> >     <SiteName>01209 - COUNTY LINe QUEBEC</SiteName>
> >     <Variance>No data at all</Variance>
> >     <Problem>This store has a communications problem</Problem>
> >   </ProblemStore>
> >   <ProblemStore>
> >     <SiteNumber>01598</SiteNumber>
> >     <SiteName>01598 - W. BANK EXPRESSWAY</SiteName>
> >     <Variance>No data at all</Variance>
> >     <Problem>This store has a communications problem</Problem>
> >   </ProblemStore>
> > </ProblemStores>
> >
> > The third line should be:
> >
> > <ProblemStores xmlns:xsd="http://tempuri.org/ProblemStores.xsd">
> >
> > Why do I care?  If you transform it with the first version - the incorrectly
> > rendered version - the XSD won't find the first node.  If you transform it
> > with the :xsd added, it renders fine.
> >
> > Is there a workaround?
> >
> > Thanks.
> >
> > S
> >
> >

AddThis Social Bookmark Button