Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to validate the XML with XSD schema
    primarykey
    data
    text
    <p>I am new to XML validation.</p> <p>My XSD is </p> <p></p> <pre><code>&lt;xsd:complexType name="RootForm"&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="TRADE" type="RecordForm" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xsd:sequence&gt; &lt;xsd:attribute name="ASOF_DATE" use="required"&gt; &lt;xsd:simpleType&gt; &lt;xsd:restriction base="xsd:string"&gt; &lt;xsd:pattern value="[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}"/&gt; &lt;/xsd:restriction&gt; &lt;/xsd:simpleType&gt; &lt;/xsd:attribute&gt; &lt;xsd:attribute name="CREATE_DATE" use="required"&gt; &lt;xsd:simpleType&gt; &lt;xsd:restriction base="xsd:string"&gt; &lt;xsd:pattern value="[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}"/&gt; &lt;/xsd:restriction&gt; &lt;/xsd:simpleType&gt; &lt;/xsd:attribute&gt; &lt;xsd:attribute name="RECORDS" type="xsd:integer" use="required"/&gt; &lt;/xsd:complexType&gt; </code></pre> <h2></h2> <p></p> <p></p> <p>The code that i an running is:</p> <pre><code>SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.setValidating(true); InputSource i = new InputSource("X:/workspace/XMLValidation/src/xml/trades.xml"); InputSource i1 = new InputSource("X:/workspace/XMLValidation/src/xml/transactions.xsd"); SAXParser saxParser = spf.newSAXParser(); saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", i1); XMLReader xmlReader = saxParser.getXMLReader(); // xmlReader.setContentHandler(new SimpleErrorHandler()); xmlReader.setErrorHandler(new SimpleErrorHandler()); try { xmlReader.parse(i); } catch (IOException e) { e.printStackTrace(); } </code></pre> <p>I get the below exception:</p> <pre><code>src-resolve.4.2: Error resolving component 'RootForm'. It was detected that 'RootForm' is in namespace 'http://www.w3schools.com', but components from this namespace are not referenceable from schema document 'file:///X:/workspace/XMLValidation/src/xml/transactions.xsd'. If this is the incorrect namespace, perhaps the prefix of 'RootForm' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///X:/workspace/XMLValidation/src/xml/transactions.xsd'. Public ID: null System ID: file:///X:/workspace/XMLValidation/src/xml/transactions.xsd Line number: 6 Column number: 52 Message: src-resolve.4.2: Error resolving component 'RootForm'. It was detected that 'RootForm' is in namespace 'http://www.w3schools.com', but components from this namespace are not referenceable from schema document 'file:///X:/workspace/XMLValidation/src/xml/transactions.xsd'. If this is the incorrect namespace, perhaps the prefix of 'RootForm' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///X:/workspace/XMLValidation/src/xml/transactions.xsd'. cvc-elt.1: Cannot find the declaration of element 'TRANSACTIONS'. </code></pre> <p>Can any one please help me what i m doing wrong in the xsd file</p> <p>Thanks Avnish</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload