• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

Correct XSD to ignore embedded markup with namespaces

Long story short, I have the following XML contained in a file (not really, but this models what I am doing):

<myElement name="myElement1">
  <Template Culture="1033">
    <asp:Label ID="Label1" runat="server" Text="Hello World!" />
  </Template>
  <Template Culture="10">
    <asp:Label ID="Label1" runat="server" Text="Hola mundo!" />
  </Template>
</myElement>

I am trying to load the file into a System.Xml.XmlDocument instance so the contents can be parsed.  Unfortunately, .NET throws an exception because it says that "asp" is an unrecognized namespace.  (Btw, an XmlReader is not appropriate because I need bi-directional access to the data.)

My thought is to create an XML Schema definition that tells .NET to treat anything inside a <Template> element as raw text and not try to parse it - I will handle that myself.  So far I have been unable to do so.

I appreciate any help figuring out how to accomplish this.
0
SonOfPirate
Asked:
SonOfPirate
1 Solution
 
Geert BormansCommented:
This is nothing you can solve with an XSD.
Schema validation needs to happen on a wellformed document.
So, the wellformedness check comes first and if you don't bind the prefix to a namespace,
this XML snippet is simply unwellformed (this means it is not XML)
You can easily tell the validating parser to not care about the content for a specific element,
if you make the content model xsd:any and validation lax.
I can show you how if you want to,
but this will not solve your problem

you will nee to change your XML like this
<myElement name="myElement1" xmlns:asp="some-uri-here>
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now