xml - XSD expects right element of wrong namespsace -


I want to define a schema in the namespace "foo", which means "schema" And what makes me remember to verify the types of "bar" types? MWE down

Root schema:

  & lt ;? XML version = "1.0" encoding = "ISO-8859-1"? & Gt; & Lt; Schema xmlns = "http://www.w3.org/2001/XMLSchema" elementFormat = "Qualified" xmlns: f = "foo" xmlns: b = "bar" targetNamespace = "foo" & gt; & Lt; Import schema location = "import.xsd" namespace = "bar" /> & Lt; Element name = "root" type = "f: root" /> & Lt; Complex type name = "root" & gt; & Lt; Sequence & gt; & Lt ;! - & lt; Element ref = "b: imported" /> - & gt; & Lt; Element name = "imported" type = "b: imported type" /> & Lt; / Sequence & gt; & Lt; / ComplexType & gt; & Lt; / Schema & gt;  

Imported schema:

   & Lt ;! - & lt; Element name = "imported" & gt; & Lt; ComplexType / & gt; & Lt; / Element & gt; - & gt; & Lt; / Schema & gt;  

XML example:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; F: root xmlns: f = "foo" xmlns: b = "bar" & gt; & Lt; P: imported / & gt; & Lt; / F: root & gt; Result:  element '{imported} times': This element is not expected, expected ({foo} has been imported.)   

If I change design patterns from Venetian blind to toggle slim (to toggle comment in schema), then everything works but all of our schemas are in VB so I would not want to make changes in this case.

Tried to validate with both XML and Notepad ++

Expect to be b: imported instead of f: imported .

This is it, you have imported and used an type and your type is already in imported type b .

Your element is imported , however (despite name) has not been imported from b , but in f Has been announced. Therefore f: imported is correct and expected.

If you want to "escape" the namespace with the element, then declare imported in f and instead use an element reference: < / P>

  & lt; Xs: element ref = "b: imported" />  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -