Advertisement

09.20.2007 at 01:45AM PDT, ID: 22840769
[x]
Attachment Details

Need help in syntax of XML schema

Asked by Edwin_C in XML Schemas for .Net, Extensible Markup Language (XML), Visual Studio .NET 2005

Tags: xml, schema

Hi
I've created a xsd file in VS2005 as below.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ReportSetting" targetNamespace="http://PopularERP/ReportSetting" elementFormDefault="qualified" xmlns="http://PopularERP/ReportSetting" xmlns:mstns="http://PopularERP/ReportSetting" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" version="1.0">
  <xs:element name="ReportSetting">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Report" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Parameter" minOccurs="0" maxOccurs="20">
                <xs:complexType>
                  <xs:sequence />
                  <xs:attribute name="Name" type="xs:string" />
                  <xs:attribute name="Prompt" type="xs:string" use="optional" />
                  <xs:attribute name="ParameterValue" type="xs:string" msprop:nullValue="_empty" use="optional" />
                  <xs:attribute name="Visible" type="xs:boolean" default="true" />
                  <xs:attribute name="Type">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:enumeration value="String" />
                        <xs:enumeration value="Integer" />
                        <xs:enumeration value="Date" />
                        <xs:enumeration value="Boolean" />
                        <xs:enumeration value="Decimal" />
                        <xs:enumeration value="CorporationId" />
                        <xs:enumeration value="Item" />
                        <xs:enumeration value="DetailAccount" />
                        <xs:enumeration value="SummaryAccount" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                </xs:complexType>
              </xs:element>
              <xs:element name="Description" type="xs:string" default="String.Empty" minOccurs="0" maxOccurs="1" />
            </xs:sequence>
            <xs:attribute name="Name" type="xs:string" />
            <xs:attribute name="PromptParameter" type="xs:boolean" />
            <xs:attribute name="Format">
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="html" />
                  <xs:enumeration value="pdf" />
                  <xs:enumeration value="xls" />
                  <xs:enumeration value="tiff" />
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="Title" type="xs:string" />
            <xs:attribute name="Folder" type="xs:string" />
            <xs:attribute name="ReportType">
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="cs" />
                  <xs:enumeration value="rpx" />
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

The problem is when I use the schema to create a new xml file as below, VS thought the xml has syntax error.
<?xml version="1.0" encoding="utf-8" ?>
<ReportSetting xmlns="http://PopularERP/ReportSetting">
  <Report Name="LOGI_02" Title="Inventory Value Report" Format="html"  PromptParameter="true" ReportType="cs" Folder="Inventory">
    <Description>Show total value of inventory as at a specific date.</Description>
    <Parameter Name="corporationId" Prompt="CorporationId" Type="CorporationId"   Visible="false"/>
    <Parameter Name="atEndOfDate" Prompt="As at end of" Type="Date" Visible="true" />
  </Report>
</ReportSetting>

When I add the first child under <Report>, the intellisense give me choices of <Description> and <Parameter>.  After adding <Description>, there is no choices for <Parameter> any more.  If I type the XML manually, the first <Parameter> is underlined saying "The element Report in namespace http://PopularERP/ReportSetting has invalid child element Parameter in namespace http://PopularERP/ReportSetting".
What I want to achieve is to have one or none <Description>  and none and multiple <Parameter> under <Report>.  Can you help me to correct my xsd if it is not defined properly?

Thanks
EdwinStart Free Trial
[+][-]09.20.2007 at 05:43AM PDT, ID: 19927751

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: XML Schemas for .Net, Extensible Markup Language (XML), Visual Studio .NET 2005
Tags: xml, schema
Sign Up Now!
Solution Provided By: drichards
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.20.2007 at 05:44AM PDT, ID: 19927757

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.20.2007 at 07:37AM PDT, ID: 19928651

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628