EDN Admin
Well-known member
Hi all;
(From a customer so I have no control over changing this) I have an XSD as follows:
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 xs<span style="color:blue :<span style="color:#a31515 schema <span style="color:red xmlns:mstns<span style="color:blue =<span style="color:black "<span style="color:blue http://tempuri.org/DSPolicies.xsd<span style="color:black " <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue http://tempuri.org/DSPolicies.xsd<span style="color:black " <span style="color:red xmlns:xs<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema<span style="color:black " <span style="color:red xmlns:msdata<span style="color:blue =<span style="color:black "<span style="color:blue urn:schemas-microsoft-com:xml-msdata<span style="color:black " <span style="color:red targetNamespace<span style="color:blue =<span style="color:black "<span style="color:blue http://tempuri.org/DSPolicies.xsd<span style="color:black " <span style="color:red elementFormDefault<span style="color:blue =<span style="color:black "<span style="color:blue qualified<span style="color:black " <span style="color:red attributeFormDefault<span style="color:blue =<span style="color:black "<span style="color:blue qualified<span style="color:black " <span style="color:red id<span style="color:blue =<span style="color:black "<span style="color:blue DSPolicies<span style="color:black "<span style="color:blue >
[/code]
And an XML as follows:
<div style="background-color:white; color:black
<pre><DSPolicies xmlns="http://tempuri.org/DSPolicies.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tempuri.org/DSPolicies.xsd
C:testthexsd.xsd
[/code]
I believe what this means is the XSD defines the default namespace to have a prefix of mstns. When I set up the context for my XmlDocument and add all the namespaces, I need to use that defined prefix from the XSD, I cant use a default one I created (I
normally use def).
Is that correct? And if the schema also uses a different prefix for a namespace with a prefix, do I need to use the XSD one or can I use the XML one?
And if so, how do I get the prefix/namespace pairs out of the XmlSchema object?
thanks - dave
ps - My code to create the XmlDocument is:
<pre lang="x-c# public XPathDataSource(Stream xmlData, Stream schemaStream, bool preserveWhitespace)
{
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.ValidationType = ValidationType.Schema;
XmlSchemaValidationFlags flags = xrs.ValidationFlags;
flags |= XmlSchemaValidationFlags.ReportValidationWarnings;
xrs.ValidationFlags = flags;
XmlSchema schema = XmlSchema.Read(schemaStream, XmlSchemaValidationErrorHandler);
xrs.Schemas.Add(schema);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.PreserveWhitespace = preserveWhitespace;
XmlReader xr = XmlReader.Create(xmlData, xrs);
xmlDoc.Load(xr);
[/code]
<
http://www.huffingtonpost.com/david-thielen/the-programming-olympics_b_972273.html The Programming Olympics - Code Wars <br/>
View the full article
(From a customer so I have no control over changing this) I have an XSD as follows:
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 xs<span style="color:blue :<span style="color:#a31515 schema <span style="color:red xmlns:mstns<span style="color:blue =<span style="color:black "<span style="color:blue http://tempuri.org/DSPolicies.xsd<span style="color:black " <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue http://tempuri.org/DSPolicies.xsd<span style="color:black " <span style="color:red xmlns:xs<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema<span style="color:black " <span style="color:red xmlns:msdata<span style="color:blue =<span style="color:black "<span style="color:blue urn:schemas-microsoft-com:xml-msdata<span style="color:black " <span style="color:red targetNamespace<span style="color:blue =<span style="color:black "<span style="color:blue http://tempuri.org/DSPolicies.xsd<span style="color:black " <span style="color:red elementFormDefault<span style="color:blue =<span style="color:black "<span style="color:blue qualified<span style="color:black " <span style="color:red attributeFormDefault<span style="color:blue =<span style="color:black "<span style="color:blue qualified<span style="color:black " <span style="color:red id<span style="color:blue =<span style="color:black "<span style="color:blue DSPolicies<span style="color:black "<span style="color:blue >
[/code]
And an XML as follows:
<div style="background-color:white; color:black
<pre><DSPolicies xmlns="http://tempuri.org/DSPolicies.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tempuri.org/DSPolicies.xsd
C:testthexsd.xsd
[/code]
I believe what this means is the XSD defines the default namespace to have a prefix of mstns. When I set up the context for my XmlDocument and add all the namespaces, I need to use that defined prefix from the XSD, I cant use a default one I created (I
normally use def).
Is that correct? And if the schema also uses a different prefix for a namespace with a prefix, do I need to use the XSD one or can I use the XML one?
And if so, how do I get the prefix/namespace pairs out of the XmlSchema object?
thanks - dave
ps - My code to create the XmlDocument is:
<pre lang="x-c# public XPathDataSource(Stream xmlData, Stream schemaStream, bool preserveWhitespace)
{
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.ValidationType = ValidationType.Schema;
XmlSchemaValidationFlags flags = xrs.ValidationFlags;
flags |= XmlSchemaValidationFlags.ReportValidationWarnings;
xrs.ValidationFlags = flags;
XmlSchema schema = XmlSchema.Read(schemaStream, XmlSchemaValidationErrorHandler);
xrs.Schemas.Add(schema);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.PreserveWhitespace = preserveWhitespace;
XmlReader xr = XmlReader.Create(xmlData, xrs);
xmlDoc.Load(xr);
[/code]
<
http://www.huffingtonpost.com/david-thielen/the-programming-olympics_b_972273.html The Programming Olympics - Code Wars <br/>
View the full article