Error whiel trying to generate class files from xsd using maven
I have the below xsd file:-
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0">
<xs:element name="ADI">
<xs:complexType>
<xs:sequence>
<xs:element name="Metadata">
<xs:complexType>
<xs:sequence>
<xs:element name="AMS">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="Asset_Class"/>
<xs:attribute type="xs:string" name="Asset_ID"/>
<xs:attribute type="xs:string" name="Asset_Name"/>
<xs:attribute type="xs:string" name="Product"/>
<xs:attribute type="xs:string" name="Provider"/>
<xs:attribute type="xs:string" name="Provider_ID"/>
<xs:attribute type="xs:byte" name="Version_Major"/>
<xs:attribute type="xs:byte" name="Version_Minor"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="App_Data" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="App" use="optional"/>
<xs:attribute type="xs:string" name="Name" use="optional"/>
<xs:attribute type="xs:string" name="Value" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
While trying to generate classes it is throwing the below expection
lineNumber: 56; columnNumber: 33; Property "Value" is already defined.
Use <jaxb:property> to resolve this conflict.
Tried using the below binding file in the same location of the xsd, but still does not work
<jxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">
<jxb:bindings schemaLocation="BaseADI.xsd">
<jxb:bindings node="//xs:element[#name='App_Data']">
<jxb:bindings node=".//xs:attribute[#name='Value']">
<jxb:property name='ValueAttribute' />
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
Then i get a parse expection:-
ERROR] Error while parsing schema(s).Location [
.........../binding.xjb{6,55}]. com.sun.istack.SAXParseException2
Is the binding file the right option to slove the issue.
Any comments or suggestions is appreciated.
Related
I've this XSD Schema definition
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://www.xxxx.xxxxxxxxx.xxxxxxxx/xxxx/xxxx">
<xs:element name="myRootElemnt">
<xs:complexType>
<xs:sequence>
<xs:element name="messageType">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:short" name="id" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element type="xs:int" name="time" />
<xs:element type="xs:short" name="date" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The generated XML is:
But, the XML still incomplete, it must contains xmlns:ns2="http://www.xxxx.xxxxxxxxx.xxxxxxxx/xxxx/xxxx"> and the prefix ns2 for the root element , like this:
Any Solutions?
My xml validation is failing with the following reason:
Failed to execute goal se.ericsson.jcat.ebs:xml-validation-plugin:1.0.2:validate (default) on project ebs-extensions: Unable to execute mojo: While parsing /home/xchoshu/latestWorkspace/ebs-extensions/src/main/resources/log4j2.xml, at file:/home/xchoshu/latestWorkspace/ebs-extensions/src/main/resources/log4j.xsd, line 18, column 64: src-resolve.4.1: Error resolving component 'ConfigurationType'. It was detected that 'ConfigurationType' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/home/xchoshu/latestWorkspace/ebs-extensions/src/main/resources/log4j.xsd'. If 'ConfigurationType' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'ConfigurationType' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/home/xchoshu/latestWorkspace/ebs-extensions/src/main/resources/log4j.xsd'. -> [Help 1]
my xds looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://logging.apache.org/log4j/2.0/config" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Configuration" type="ConfigurationType"/>
<xs:complexType name="ConfigurationType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="CustomLevels" type="CustomLevelsType"/>
<xs:element name="CustomLevel" type="CustomLevelType"/>
</xs:choice>
<xs:element name="Properties" type="PropertiesType"/>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="Filters" type="FiltersType"/>
<xs:element name="Filter" type="FilterType"/>
</xs:choice>
<xs:element name="ThresholdFilter" type="ThresholdFilterType"/>
<xs:element name="Appenders" type="AppendersType"/>
<xs:element name="Loggers" type="LoggersType"/>
</xs:sequence>
<xs:attribute name="packages" type="xs:string"/>
<xs:attribute name="status" type="xs:string"/>
<xs:attribute name="strict" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="advertiser" type="xs:string"/>
<xs:attribute name="schema" type="xs:string"/>
</xs:complexType>
<xs:complexType name="PropertiesType">
<xs:sequence>
<xs:element name="Property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AppenderType">
<xs:sequence>
<xs:element name="Layout" type="LayoutType" minOccurs="0"/>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="Filters" type="FiltersType"/>
<xs:element name="Filter" type="FilterType"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="fileName" type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="RootType">
<xs:sequence>
<xs:element name="AppenderRef" type="AppenderRefType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="level" type="xs:string"/>
</xs:complexType>
<xs:complexType name="PropertyType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="KeyValuePairType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="key" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="AppendersType">
<xs:sequence>
<xs:element name="Appender" type="AppenderType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AppenderRefType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="ref" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="LoggerType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="Filters" type="FiltersType"/>
<xs:element name="Filter" type="FilterType"/>
</xs:choice>
<xs:element name="AppenderRef" type="AppenderRefType"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="level" type="xs:string" use="optional"/>
<xs:attribute name="additivity" type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="FilterType" mixed="true">
<xs:sequence>
<xs:element name="KeyValuePair" type="KeyValuePairType" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="level" type="xs:string" use="optional"/>
<xs:attribute name="marker" type="xs:string" use="optional"/>
<xs:attribute name="onMatch" type="xs:string" use="optional"/>
<xs:attribute name="onMismatch" type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="FiltersType">
<xs:sequence>
<xs:element name="Filter" type="FilterType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CustomLevelType">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="intLevel" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="CustomLevelsType">
<xs:sequence>
<xs:element name="CustomLevel" type="CustomLevelType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="LoggersType" mixed="true">
<xs:sequence>
<xs:element name="Logger" type="LoggerType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Root" type="RootType" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="LayoutType" mixed="true">
<xs:sequence>
<xs:element name="Pattern" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="pattern" type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="ThresholdFilterType">
<xs:attribute name="level" type="xs:string" use="optional"/>
<xs:attribute name="onMatch" type="xs:string" use="optional"/>
<xs:attribute name="onMismatch" type="xs:string" use="optional"/>
</xs:complexType>
</xs:schema>
my xml looks like:
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://logging.apache.org/log4j/2.0/config"
xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config https://ei-switching.rnd.ki.sw.ericsson.se/browser/jcat-bsp/log4j.xsd">
<Appenders>
<Console name="JCATDefaultConsoleAppender" target="SYSTEM_OUT"
follow="true">
<PatternLayout pattern="%d{default} %m [%t] %l%n%ex{full}" />
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="JCATDefaultConsoleAppender" />
</Root>
</Loggers>
can anyone help me in correcting the xsd.
TIA
Regards,
Shubhankar
The XSD is missing the namespace declaration xmlns="http://logging.apache.org/log4j/2.0/config". That makes the XSD valid.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://logging.apache.org/log4j/2.0/config"
targetNamespace="http://logging.apache.org/log4j/2.0/config"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Configuration" type="ConfigurationType"/>
But then your XML files has lots of issues
You are missing the mandatory elements Properties and ThresholdFilters and Appenders should contain at least 1 Appender (not a Console)
A Sample document would look something like this
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid XML 2017 Liquid Studio - Data Designer Edition 15.0.0.6978 (https://www.liquid-technologies.com) -->
<ns:Configuration xmlns:ns="http://logging.apache.org/log4j/2.0/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config C:\Temp\StackOverflow\41177776\Schema.xsd" packages="string" status="string" strict="string" name="string" advertiser="string" schema="string">
<ns:CustomLevels><!--optional-->
<ns:CustomLevel name="string" intLevel="string" />
<ns:CustomLevel name="string" intLevel="string" />
<ns:CustomLevel name="string" intLevel="string" />
</ns:CustomLevels>
<ns:Properties>
<ns:Property>string</ns:Property>
<ns:Property>string</ns:Property>
</ns:Properties>
<ns:Filters><!--optional-->
<ns:Filter type="string" level="string" marker="string" onMatch="string" onMismatch="string">
<ns:KeyValuePair key="string" value="string">string</ns:KeyValuePair>
</ns:Filter>
</ns:Filters>
<ns:ThresholdFilter level="string" onMatch="string" onMismatch="string" />
<ns:Appenders>
<ns:Appender type="string" name="string" fileName="string" />
<ns:Appender type="string" name="string" />
</ns:Appenders>
<ns:Loggers>
<ns:Logger name="string" level="string" additivity="string">
<ns:AppenderRef ref="string">string</ns:AppenderRef>
</ns:Logger>
<ns:Root>
<ns:AppenderRef ref="string">string</ns:AppenderRef>
</ns:Root>
</ns:Loggers>
</ns:Configuration>
I saw that this question was asked many times but I didn't find a solution to my problem. So the error is:
Error on line 2 of document file...doc.xsd: cvc-elt.1: Cannot find the declaration of element 'xs:schema'
The code in the XSD file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Collection" >
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string"/>
<xs:element name="Recipe" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Ingredients">
<xs:complexType>
<xs:element name="Ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="amount" type="xs:integer" use="required"/>
<xs:attribute name="unit" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
<xs:element name="Preparation">
<xs:complexType>
<xs:element name="Step" type="xs:string minOccurs="0" maxOccurs="unbounded"/>"
</xs:complexType>
</xs:element>
<xs:element name="Comment" type="xs:string" minOccurs="0"/>
<xs:element name="Nutrients">
<xs:complexType>
<xs:attribute name="proteins" type="xs:integer" use="required"/>
<xs:attribute name="carbohidrati" type="xs:NMTOKEN" use="required"/>
<xs:attribute name="fat" type="xs:integer" use="choice"/>
<xs:attribute name="vitamins" type="xs:NMTOKEN" use="required"/>
<xs:attribute name="calories" type="xs:float" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The code in the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="src/doc.xsd">
<Description>Nu prea merge</Description>
<Recipe>
<Title>Paste</Title>
<Ingredients>
<Ingredient name="paste" amount="1" unit="pachet"></Ingredient>
</Ingredients>
<Preparation>
<Step>Fierbere</Step>
<Step>Servire</Step>
</Preparation>
<Nutrients proteins="2" carbohidrati="2" fat="da" vitamins="4" calories="1000.9"></Nutrients>
</Recipe>
</Collection>
The code in my Java class:
import java.io.File;
import java.io.IOException;
import org.jdom2.Document;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.jdom2.input.sax.XMLReaders;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
public class Main {
public static void main(String[] args) {
File newFile = new File("src/doc.xsd");
Document doc = null;
SAXBuilder sbd = new SAXBuilder(XMLReaders.XSDVALIDATING);
try {
doc = sbd.build(newFile);
} catch (JDOMException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XMLOutputter outputDoc = new XMLOutputter();
outputDoc.setFormat(Format.getPrettyFormat());
try{
outputDoc.output(doc,System.out);
//outputDoc.output(doc, new FileWriter("src/myXmlDoc2.xml"));
}
catch(Exception e){
System.out.println("Eroare la parsarea documentului XML!");
}
}
}
If anyone has any idea about the possible problem please help me!
Assuming that your XML is fixed, then you should change your XSD as follows:
Fix the extra " as mentioned by #Andreas.
Add xs:sequence under xs:complexType in two places.
Change the type of #fat to xs:string.
Change use="choice" to use="optional".
Altogether, this XSD will successfully validate your XML:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Collection" >
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string"/>
<xs:element name="Recipe" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Ingredients">
<xs:complexType>
<xs:sequence>
<xs:element name="Ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="amount" type="xs:integer" use="required"/>
<xs:attribute name="unit" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Preparation">
<xs:complexType>
<xs:sequence>
<xs:element name="Step" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Comment" type="xs:string" minOccurs="0"/>
<xs:element name="Nutrients">
<xs:complexType>
<xs:attribute name="proteins" type="xs:integer" use="required"/>
<xs:attribute name="carbohidrati" type="xs:NMTOKEN" use="required"/>
<xs:attribute name="fat" type="xs:string" use="optional"/>
<xs:attribute name="vitamins" type="xs:NMTOKEN" use="required"/>
<xs:attribute name="calories" type="xs:float" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Of course, you will also have to check your Java code. (Hint: make sure you're not validating your XSD as XML when you really want to validating your XML against your XSD.)
I have to modify a project using XSD validation. I had got an XML, I transformed it to XSD via Intellij and then generated the associated code with the JAXB tool. All was fine.
But for the project needs, I had to modify the entire structure of my XML, I did it. I generate the XSD as well. But, When I tried to generate the Java code via the jaxb tools, it was impossible.
When I click in this jaxb tool, it just generated another XSD.
How can I do to generate, once again, the code ?
Thank you !
There is my XSD.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="PurgeConfigurationRacine" type="PurgeConfigurationRacineType"/>
<xs:complexType name="BusinessBaseType">
<xs:sequence>
<xs:element type="ArchiveDataOperationType" name="ArchiveDataOperation"/>
<xs:element type="PurgeDataOperationType" name="PurgeDataOperation"/>
<xs:element type="DeleteArchivedDataOperationType" name="DeleteArchivedDataOperation"/>
</xs:sequence>
<xs:attribute type="xs:string" name="dataSourceRef"/>
</xs:complexType>
<xs:complexType name="SqlQueryType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name" use="optional"/>
<xs:attribute type="xs:string" name="step" use="optional"/>
<xs:attribute type="xs:string" name="multi" use="optional"/>
<xs:attribute type="xs:string" name="param" use="optional"/>
<xs:attribute type="xs:string" name="value" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ArchiveDataOperationType">
<xs:sequence>
<xs:element type="SqlQueryType" name="SqlQuery" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PurgeDataOperationType">
<xs:sequence>
<xs:element type="SqlQueryType" name="SqlQuery" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PurgeConfigurationRacineType">
<xs:sequence>
<xs:element type="BusinessBaseType" name="BusinessBase"/>
<xs:element type="DataBaseType" name="DataBase"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DeleteArchivedDataOperationType">
<xs:sequence>
<xs:element type="SqlQueryType" name="SqlQuery" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DataBaseType">
<xs:sequence>
<xs:element type="ArchiveDataOperationType" name="ArchiveDataOperation"/>
<xs:element type="PurgeDataOperationType" name="PurgeDataOperation"/>
</xs:sequence>
<xs:attribute type="xs:string" name="dataSourceRef"/>
</xs:complexType>
</xs:schema>
The problem that you are facing is a known issue, it is due to the fact that you have an attribute called value which is a protected name, such that you need to specify to xjc that it has to use a different name, it can be done by adding some meta information in your XSD file as next:
<xs:attribute type="xs:string" name="value" use="optional">
<xs:annotation>
<xs:appinfo>
<jaxb:property name="sqlQueryTypeValue"/>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
You will also need to add the corresponding namespace declaration and the jaxb version to use, for example:
<xs:schema ... xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1">
More information about how to customize JAXB binding
In my xsd, I have something like this:
<xs:complexType name="Disk">
<xs:attribute name="index" type="xs:int"></xs:attribute>
<xs:attribute name="providerId" type="xs:int"></xs:attribute>
<xs:attribute name="size" type="xs:int"></xs:attribute>
</xs:complexType>
<xs:complexType name="Server">
<xs:sequence>
<xs:element name="Disk" maxOccurs="unbounded" type="Disk"></xs:element>
</xs:sequence>
</xs:complexType>
I generated JAXB classes from above xsd and create an object of type Server and populated the arraylist named disk. Now when I try to marshal Server object to xml, I see:
<server><Disk index="0" providerId="123" size="10000"/><Disk index="1" providerId="1234" size="10000"/></server>
Is there any way by which I should see XML like:
<server><Disks><Disk index="0" providerId="123" size="10000"/><Disk index="1" providerId="1234" size="10000"/></Disks></server>
I want the list of disks xml tags to be enclosed in the tag. If it is possible, how to do it?
If u want tag can occurs many times in server tag use this.
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Disk">
<xs:attribute name="index" type="xs:int"></xs:attribute>
<xs:attribute name="providerId" type="xs:int"></xs:attribute>
<xs:attribute name="size" type="xs:int"></xs:attribute>
</xs:complexType>
<xs:complexType name="Server">
<xs:sequence>
<xs:element name="Disks" maxOccurs="unbounded" type="Disks"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Disks">
<xs:sequence>
<xs:element name="Disk" maxOccurs="unbounded" type="Disk"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
Or if you want Disks tag only once use following XSD
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Disk">
<xs:attribute name="index" type="xs:int"></xs:attribute>
<xs:attribute name="providerId" type="xs:int"></xs:attribute>
<xs:attribute name="size" type="xs:int"></xs:attribute>
</xs:complexType>
<xs:complexType name="Server">
<xs:sequence>
<xs:element name="Disks" minOccurs="0" maxOccurs="1" type="Disks"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Disks">
<xs:sequence>
<xs:element name="Disk" maxOccurs="unbounded" type="Disk"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>