[quoted text, click to view] "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:edeD6SoaEHA.2840@TK2MSFTNGP11.phx.gbl...
> Mythran wrote:
> > Wish it were that simple. elementFormDefault attribute already set.
>
> Oops I was wrong. elementFormDefault is only about locally defined
> elements, while you are talking about root element.
>
> >>>1.) How can I get xml to be valid using <Configuration> rather than
> >>><cfg:Configuration> when it loads? I'd rather use <Configuration> as it's
>
> Basically there is no difference whether you are using prefixed
> namespace or default namespace. Just make sure your schema defines
> Configuration element in that namespace:
>
> <xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified" xmlns:blah="Blah" targetNamespace="Blah">
> <xs:element name="Configuration">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="foo" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> then both
>
> <Configuration xmlns="Blah"
> xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="Blah foo.xsd">
> <foo/>
> </Configuration>
>
> and
>
> <blah:Configuration xmlns:blah="Blah"
> xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="Blah foo.xsd">
> <blah:foo/>
> </blah:Configuration>
>
> are valid.
>
Tell that to .Net! :P
All of the above are valid, and can load, with one exception...
<!--Sample.xml-->
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="MCIS.Applications.Reports.Schema.Configuration">
<Report Path="crystalreports\Balance Sheet.rpt">
<ExportOptions FileNameFormat="Balance Sheet {0:MM-dd-yyyy HH.mm.ss tt}"
FileNameFormatValue="Date"
OutputFolder="pdfs"
OutputType="PortableDocFormat"
/>
</Report>
</Configuration>
It doesn't load, keeps giving me an error:
The element 'MCIS.Applications.Reports.Schema.Configuration:Configuration' has
invalid child element 'MCIS.Applications.Reports.Schema.Configuration:Report'.
Expected 'Report'. An error occurred at file:///C:/path/sample.xml, (4, 6).
Same things for ExportOptions and Report elements (the above message is repeated
a total of 3 times in the exception message).
The first part of the xsd file is:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Configuration"
targetNamespace="MCIS.Applications.Reports.Schema.Configuration"
elementFormDefault="unqualified" attributeFormDefault="unqualified"
xmlns="MCIS.Applications.Reports.Schema.Configuration"
xmlns:mstns="MCIS.Applications.Reports.Schema.Configuration"
xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:annotation>
<xs:documentation>MCIS Automated Reports</xs:documentation>
</xs:annotation>
<xs:element name="Configuration" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Report" type="Report" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:simpleType name="ExportTypes" id="ExportTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="NoFormat" />
<xs:enumeration value="CrystalReport" />
<xs:enumeration value="RichText" />
<xs:enumeration value="WordForWindows" />
<xs:enumeration value="Excel" />
<xs:enumeration value="PortableDocFormat" />
<xs:enumeration value="HTML32" />
<xs:enumeration value="HTML40" />
<xs:enumeration value="ExcelRecord" />
</xs:restriction>
</xs:simpleType>
Hope this helps shed some more light ;)
Mythran