简体   繁体   中英

Using LiquidXML with noNamespaceSchemaLocation

When I generate my C# code I get a namespace with 'AA' when noNamespaceSchemaLocation is defined?

The docs talk about adding a NamespaceAlias to the Default context here: http://www.liquid-technologies.com/Reference/XmlDataBinding/source/HowTo/ChangeNamespaceAliases.htm

But there is no mention of noNamespaceSchemaLocation?

I assume you are trying to create XML that looks a bit like this

<RootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.foo.com/schemaDirectory/bar.xsd" ...>

But your getting something that looks like this

<RootElement xmlns:AA="http://www.w3.org/2001/XMLSchema-instance" AA:noNamespaceSchemaLocation="http://www.foo.com/schemaDirectory/bar.xsd" ...>

In order to get the namespace alias 'xsi' instead of 'AA' (or similar) you need to define the namespace ' http://www.w3.org/2001/XMLSchema-instance ', this can be done like this:-

LiquidTechnologies.Runtime.Net40.XmlSerializationContext.Default.NamespaceAliases.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM