Valitadion of xml with schema declared in it

Hey,
I can compile this and run it; but I don't know if it works because it will not throw any exceptions if I change my xmlfile to be not valid. So I'm not getting any printouts...
This is not good at all. What have I done wrong? I'm totally new to this so this code might look bad. If it does, don't hesitate to just tell me.
public class Validation {
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
static final File xmlFile = new File("C:/Documents and Settings/erm/My Documents/xml/generated_xml.xml");
public Validation()
public static void main(String args [])
parser();
public static void parser()
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
DefaultHandler handler = new DefaultHandler();
try{
SAXParser saxParser = factory.newSAXParser();
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
saxParser.parse(xmlFile, handler);
catch(SAXParseException se)
System.out.println("Bla bla..." + se);
catch(Exception e)
System.out.println("Bla bla..." + e);
Am I suppose to declare this method in the class as well? It is in my class "Validation" as it is now...
public void error(SAXParseException e)
throws SAXParseException
throw e;
Thanks / Elin

This is the start of my XML-file, is this what you're talking about?
<?xml version="1.0" encoding="ISO-8859-1"?>
<ship_performance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\erm\My Documents\ships performance\draft2.xsd">
     <source_application>integrity</source_application>
/ Elin

Similar Messages

  • Problem parsing XML with schema when extracted from a jar file

    I am having a problem parsing XML with a schema, both of which are extracted from a jar file. I am using using ZipFile to get InputStream objects for the appropriate ZipEntry objects in the jar file. My XML is encrypted so I decrypt it to a temporary file. I am then attempting to parse the temporary file with the schema using DocumentBuilder.parse.
    I get the following exception:
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element '<root element name>'
    This was all working OK before I jarred everything (i.e. when I was using standalone files, rather than InputStreams retrieved from a jar).
    I have output the retrieved XML to a file and compared it with my original source and they are identical.
    I am baffled because the nature of the exception suggests that the schema has been read and parsed correctly but the XML file is not parsing against the schema.
    Any suggestions?
    The code is as follows:
      public void open(File input) throws IOException, CSLXMLException {
        InputStream schema = ZipFileHandler.getResourceAsStream("<jar file name>", "<schema resource name>");
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;
        try {
          factory.setNamespaceAware(true);
          factory.setValidating(true);
          factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
          factory.setAttribute(JAXP_SCHEMA_SOURCE, schema);
          builder = factory.newDocumentBuilder();
          builder.setErrorHandler(new CSLXMLParseHandler());
        } catch (Exception builderException) {
          throw new CSLXMLException("Error setting up SAX: " + builderException.toString());
        Document document = null;
        try {
          document = builder.parse(input);
        } catch (SAXException parseException) {
          throw new CSLXMLException(parseException.toString());
        }

    I was originally using getSystemResource, which worked fine until I jarred the application. The problem appears to be that resources returned from a jar file cannot be used in the same way as resources returned directly from the file system. You have to use the ZipFile class (or its JarFile subclass) to locate the ZipEntry in the jar file and then use ZipFile.getInputStream(ZipEntry) to convert this to an InputStream. I have seen example code where an InputStream is used for the JAXP_SCHEMA_SOURCE attribute but, for some reason, this did not work with the InputStream returned by ZipFile.getInputStream. Like you, I have also seen examples that use a URL but they appear to be URL's that point to a file not URL's that point to an entry in a jar file.
    Maybe there is another way around this but writing to a file works and I set use File.deleteOnExit() to ensure things are tidied afterwards.

  • Persisting unexplained errors when parsing XML with schema validation

    Hi,
    I am trying to parse an XML file including XML schema validation. When I validate my .xml and .xsd in NetBeans 5.5 beta, I get not error. When I parse my XML in Java, I systematically get the following errors no matter what I try:
    i) Document root element "SQL_STATEMENT_LIST", must match DOCTYPE root "null".
    ii) Document is invalid: no grammar found.
    The code I use is the following:
    try {
    Document document;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File(PathToXml) );
    My XML is:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!-- Defining the SQL_STATEMENT_LIST element -->
    <xs:element name="SQL_STATEMENT_LIST" type= "SQL_STATEMENT_ITEM"/>
    <xs:complexType name="SQL_STATEMENT_ITEM">
    <xs:sequence>
    <xs:element name="SQL_SCRIPT" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <!-- Defining simple type ApplicationType with 3 possible values -->
    <xs:simpleType name="ApplicationType">
    <xs:restriction base="xs:string">
    <xs:enumeration value="DawningStreams"/>
    <xs:enumeration value="BaseResilience"/>
    <xs:enumeration value="BackBone"/>
    </xs:restriction>
    </xs:simpleType>
    <!-- Defining the SQL_SCRIPT element -->
    <xs:element name="SQL_SCRIPT" type= "SQL_STATEMENT"/>
    <xs:complexType name="SQL_STATEMENT">
    <xs:sequence>
    <xs:element name="NAME" type="xs:string"/>
    <xs:element name="TYPE" type="xs:string"/>
    <xs:element name="APPLICATION" type="ApplicationType"/>
    <xs:element name="SCRIPT" type="xs:string"/>
    <!-- Making sure the following element can occurs any number of times -->
    <xs:element name="FOLLOWS" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    and my XML is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Document : SQLStatements.xml
    Created on : 1 juillet 2006, 15:08
    Author : J�r�me Verstrynge
    Description:
    Purpose of the document follows.
    -->
    <SQL_STATEMENT_LIST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://www.dawningstreams.com/XML-Schemas/SQLStatements.xsd">
    <SQL_SCRIPT>
    <NAME>CREATE_PEERS_TABLE</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE CACHED TABLE PEERS (
    PEER_ID           VARCHAR(20) NOT NULL,
    PEER_KNOWN_AS      VARCHAR(30) DEFAULT ' ' ,
    PRIMARY KEY ( PEER_ID )
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>CREATE_COMMUNITIES_TABLE</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE CACHED TABLE COMMUNITIES (
    COMMUNITY_ID VARCHAR(20) NOT NULL,
    COMMUNITY_KNOWN_AS VARCHAR(25) DEFAULT ' ',
    PRIMARY KEY ( COMMUNITY_ID )
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>CREATE_COMMUNITY_MEMBERS_TABLE</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE CACHED TABLE COMMUNITY_MEMBERS (
    COMMUNITY_ID VARCHAR(20) NOT NULL,
    PEER_ID VARCHAR(20) NOT NULL,
    PRIMARY KEY ( COMMUNITY_ID, PEER_ID )
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>DROP_PEER_TABLE</NAME>
    <TYPE>DELETION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    DROP TABLE PEERS IF EXISTS
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>DROP_COMMUNITIES_TABLE</NAME>
    <TYPE>DELETION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    DROP TABLE COMMUNITIES IF EXISTS
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>DROP_COMMUNITY_MEMBERS_TABLE</NAME>
    <TYPE>DELETION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    DROP TABLE COMMUNITY_MEMBERS IF EXISTS
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>CREATE_COMMUNITY_MEMBERS_VIEW</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE VIEW COMMUNITY_MEMBERS_VW AS
    SELECT P.PEER_ID, P.PEER_KNOWN_AS, C.COMMUNITY_ID, C.COMMUNITY_KNOWN_AS
    FROM PEERS P, COMMUNITIES C, COMMUNITY_MEMBERS CM
    WHERE P.PEER_ID = CM.PEER_ID
    AND C.COMMUNITY_ID = CM.COMMUNITY_ID
    </SCRIPT>
    <FOLLOWS>CREATE_PEERS_TABLE</FOLLOWS>
    <FOLLOWS>CREATE_COMMUNITIES_TABLE</FOLLOWS>
    </SQL_SCRIPT>
    </SQL_STATEMENT_LIST>
    Any ideas? Thanks !!!
    J�r�me Verstrynge

    Hi,
    I found the solution in the following post:
    Validate xml with DOM - no grammar found
    Sep 17, 2003 10:58 AM
    The solution is to add a line of code when parsing:
    try {
    Document document;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File(PathToXml) );
    The errors are gone !!!
    J�r�me Verstrynge

  • IllegalArgumentException - error validating xml with schema

    I'm trying to validate an XML document using the following:
    JAXP 1.2
    Xerces 1.4.4
    JDK 1.4.1
    The xml is valid and I can confirm it with XML Spy when I point it to the schema definition. But, I get an IllegalArgumentException when I try to do it in my class.
    Here's the code...
    public static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    public static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
    public static final String CIS_SCHEMA = "D:\\dev\\xml\\cis.xsd";
    public static final String[] SCHEMAS = { W3C_XML_SCHEMA, CIS_SCHEMA };
    private static DocumentBuilderFactory dbf;
    private static DocumentBuilder db;
    try {
         dbf.setNamespaceAware(true);
         dbf.setValidating(true);
         dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, SCHEMAS);
    } (catch ...) {
    I get the following error:
    java.lang.IllegalArgumentException: http://java.sun.com/xml/jaxp/properties/schemaLanguage
    Any ideas?

    When I tried this with Xerces SAX, I got---
    org.xml.sax.SAXNotRecognizedException: http://java.sun.com/xml/jaxp/properties/schemaLanguage
    Maybe Xerces has not implemented the schemaLanguage property.
    I have been successfully using Xerces-dependent properties to do validation:
    XMLReader parser = saxParser.getXMLReader();
    parser.setFeature( "http://xml.org/sax/features/validation", true);
    parser.setFeature( "http://xml.org/sax/features/namespaces", true);
    parser.setFeature( "http://apache.org/xml/features/validation/schema", true);
    parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);
    if (noNamespaceSchemaLocation!=null) {
    parser.setProperty(
    "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
    noNamespaceSchemaLocation);
    if (schemaLocation!=null) {
    parser.setProperty(
    "http://apache.org/xml/properties/schema/external-schemaLocation",
    schemaLocation);
    Also, as DrClap pointed out, for the schema location I use URIs.
    Please let me know if you got the jaxp schemaLocation property to work and how you did it.

  • Undigesting XML with Schema and Rules

    We currently use a Digester with schema and rules files to digest an input XML and automatically build our Java objects. What I'd like to know is if there is a REVERSE process? Is there any class or utility that can take those Java objects and build an XML file?
    Thanks,
    Rich

    Ask Microsoft why IE6 does not validate. Normally server-side developers do
    not rely on a browser to validate XML against schema or DTD but validate XML
    on the server. The same is true for XSLT transformations...
    "Benoit Degreve" <[email protected]> wrote in message
    news:aqnihv$l75$[email protected]..
    Hi everybody,
    I'm trying to validate an XML file with a schema but it doesn't seem to
    work.
    I open the XML file (that doesn't match the rules that are in the schema)
    with a IE6, and there is no errors...
    I have the same problem with a DTD (its reference is in the XML file like
    shown in my book)...
    Does the validation process have to be done by a specific application ?For
    the schema ? For the DTD ? In other words, does IE6 make the validation
    process automatically ?
    Could someone help me ?

  • Validation of XML with Schema, which contains more than one Schema

    Hi All,
    I am having a parent.xsd file, which inculdes or imports child.xsd file. I need to validate an xml with the parent xsd. Could u give any sample code for doing the same.
    Java Version : 1.4.2
    Using Xerces for parsing the xml....
    Thanks,
    Senthil

    Is anyone there to reply?

  • Validate XML with Schema?

    So, according to Adobe...
    quote:
    Dreamweaver CS3 continues to support not only the creation
    and editing of XML and XSL files, but it also allows you to import
    DTDs and schemas and to validate XML documents.
    Does anyone know how to accomplish this task? Adobe's
    documentation on this topic seems be less current than their
    marketing material.
    I mean, I'm assuming from the way this is worded it means
    that you can "import DTDs and schemas and ... validate XML
    documents"
    with said schemas. Or is this just some shifty marketing
    trickery which really means you can import (i.e., open) a DTD or
    schema, and, as a completely unrelated task, you can "validate"
    your XML file - to the extent that Dreamweaver will tell you if you
    forgot to close a tag?

    I tried to move all the xml, class and xsd files in the same folder and it still didn't work...
    And I can't hard coded the xsd file on the document... so the only way is to set the xsd location inside the java codes... here's what I have:
    static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
    static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    File xsdFile = new File("schema.xsd");
    saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
    saxParser.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);
    Please help... thx.

  • Partial Validation of XML with Schema

    This might be a quick question with a 'yes' or 'no' answer.
    What I have is a large XML file. It has various tags that are headers to keep groups of information together. I want to create an XML Schema that validates only one section of the overall larger XML file.
    First, is this possible to do, and if so, how exactly do I go about doing it?????
    Any code would be great, but if there I think it would be more useful to see how the XSL might be defined.
    <root>
    <section1>
    </section1>
    <section2>
    <!-- How would I define a W3C Schema to validate only this section? -->
    </section2>
    <section3>
    </section3>
    </root>
    Again, any help would be much appreciated?
    Thanks.
    Tom

    The existing schema validation doesn't let you do that... however you sure can get around it. I wrote some program that let you validate one field at a time, or one record at a time rather than whole document.
    I did so by using directly the DataTypeValidator inside org.apache.xerces.validators.*... it requires some coding, because you will have to write your own validator and some sort of filter... but you should look at the codes in that package to get a better understanding.

  • Indices and constraints on XML Tables/Columns (with Schema)

    Hi,
    I've read a lot of documents by know, but the more I read the more I got confused. So I hope you can help me.
    Frist my Oracle Server Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
    I've manages to create a table with a column with the type SYS.XMLTYPE and the storage modle "Object Relational" with an XML Schema.
    I can insert data and I can execute XQuery statements.
    I can also create an XMLTYPE table with my Schema, althoug the tool SQL Developer keeps telling me, that the one column wich is generated within the table is of the type CLOB instead of object realtional (which is what I defined).
    The query for that is:
    CREATE TABLE ENTRY_XML OF XMLTYPE
    XMLTYPE STORE AS OBJECT RELATIONAL
    XMLSCHEMA "BBMRI_Entry.xsd" ELEMENT "Entry";
    That's where I am, now my questions:
    1. What's the difference? I'm aware of the obviouse difference, that with the first way I can add relational columns as well, but apart from that? If I only want to store the xml data, is the second approach always better (especially in regard to my next question)?
    2. My schema contains elements with attributes (which contain IDs), which have to be unique. So I tried to add a UNIQUE constraint, but failed. I found this (http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/constraints/Specify_Constraints.html), but it just doesn't work.
    Query: "ALTER TABLE ENTRY_XML CONSTRAINT ENTRY_XML_SUBID_UNQIUE UNIQUE (xmldata."SubId");"
    Error: "ORA-01735: invalid ALTER TABLE option"
    3. I didn't try yet, but I need to specifiy foreign keys within the XML as well (which is explained in the link at question 2). I guess the solution to question 2 will make this possible as well.
    4. Since I can create a UNIQUE constaint for attributes (well, I can't yet, but I hope that this will change soon) I woundered if it would be possible to realize something like auto_increment. Although I see the problem with validating the xml input if the Ids are empty. Any suggestions on that problem? Do I have to query for the highest (free) id before I can insert the new documents?
    Well, that's enough for today, I hope someone can help me!
    Greetings, Florian

    I've read through all the literature (again) and found out, that I did most of the stuff right in the first place. I just missinterpreted the generated tables for the types and wondered why they only contained one column. Well, at least one mistery solved.
    But know to make it easier just one question, which might solve all problems I have:
    How can I create UNIQUE constraints and FOREIGN KEYS when I have a table or column of the type XmlType with a schema using the object relational storage method?
    I found a solution http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb05sto.htm#i1042421 (Example 5-12), but it just does not work for me.
    I removed the FOREIGN KEY and tried it again and the UNIQUE Key works.
    So basically the question is how to retrieve the "AId" Attribute. "XMLDATA"."AId", "XMLDATA"."Attribute"."AId" and "XMLDATA"."Subject"."Attribute"."AId" all do not work.
    I've added my schema declarations at the bottom (which I've already successfully registred and used without foreign keys and constraints, so they work).
    After I've registered the two schema files 3 types and 11 tables where created. One type for the attribute, one for the study type and one probably to link the attributes to the study types. The tables are one for the attribute, 4 for the content*-elements, 2 for the study type (I don't really know why two) and 4 with strange names starting with "SYS_NT" and then some random numbers and letters (looks alot like some base64 encoded string).
    The Query I try to use to create the table is: (The table "Attribute" already exists and contains a field "ID", which is it's PK.)
    CREATE TABLE STUDYTYPE_XML
    OF XMLType (UNIQUE ("XMLDATA"."STId"),
    FOREIGN KEY ("XMLDATA"."AId") REFERENCES ATTRIBUTE(ID))
    XMLTYPE STORE AS OBJECT RELATIONAL
    ELEMENT "StudyType.xsd#StudyType";
    The error I get is:
    Error starting at line 1 in command:
    CREATE TABLE STUDYTYPE_XML
    OF XMLType (UNIQUE ("XMLDATA"."STId"),
    FOREIGN KEY ("XMLDATA"."AId") REFERENCES ATTRIBUTE(ID))
    ELEMENT "StudyType.xsd#StudyType"
    Error at Command Line:3 Column:37
    Error report:
    SQL Error: ORA-22809: nonexistent attribute
    22809. 00000 - "nonexistent attribute"
    Cause: An attempt was made to access a non-existent attribute of an
    object type.
    Action: Check the attribute reference to see if it is valid. Then retry
    the operation.
    Attribute-Schema (Attribute.xsd):
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:attribute name="AId">
              <xs:simpleType>
                   <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0" />
                   </xs:restriction>
              </xs:simpleType>
         </xs:attribute>
         <xs:attribute name="Name" type="xs:string" />
         <xs:element name="ContentString" type="xs:string" />
         <xs:element name="ContentInteger" type="xs:integer" />
         <xs:element name="ContentDouble" type="xs:decimal" />
         <xs:element name="ContentDate" type="xs:date" />
         <xs:element name="Attribute">
              <xs:complexType>
                   <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element ref="ContentString" />
                        <xs:element ref="ContentInteger" />
                        <xs:element ref="ContentDouble" />
                        <xs:element ref="ContentDate" />
                   </xs:choice>
                   <xs:attribute ref="AId" use="required" />
                   <xs:attribute ref="Name" use="optional" />
              </xs:complexType>
         </xs:element>
    </xs:schema>
    Study Type Schema (StudyType.xsd):
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:include schemaLocation="Attribute.xsd" />
         <xs:attribute name="STId">
              <xs:simpleType>
                   <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0" />
                   </xs:restriction>
              </xs:simpleType>
         </xs:attribute>
         <xs:element name="StudyType">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="Attribute" minOccurs="1" maxOccurs="unbounded" />
                        <xs:element ref="StudyType" minOccurs="0" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute ref="STId" use="required"/>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    Edited by: alwaysspam on Sep 8, 2010 5:35 PM

  • Xml validation with schema, unbounded and any order of elements

    Hi
    I want to validate a xml file the user creates. I am currently using schema to do this. However there needs to be the possibility of a totally random mix of three different types of elements in a parent element. I couldn't find out how to do this, maybe it is not possible with schema? I thought I could look at the error message generated and ignore it if it was caused by one of the three elements mentioned above, but while the error message generated says which element is expected, it does not say which element caused the error.
    Thanks in advance for any help.

    Ruskin wrote:
    However there needs to be the possibility of a totally random mix of three different types of elements in a parent element. Can you take your example to make it more clear? Does all three elements mutually exclusive?

  • JSTL - Problem parsing XML file w/ XML schema declarations

    I'm having trouble parsing an xml document that contains XML schema declarations in the root element. I've included 2 snippets, the XML files they're supposed to parse, and their output below. The first one works and the second one doesn't. Could someone please tell me why? I find it hard to believe that no one's run into this before.
    I'm running Tomcat 5.5 and I'm using JSP 2.0, jakarta standard taglibs jars (1.1.2), jdk 1.5.0_04, and the Xalan 2.7.0 jars.
    Here's the first snippet:
    <c:import url="/WEB-INF/config/schools.xml" var="xml" />
    <x:parse doc="${xml}" var="schoolList"/>
    There are <x:out select="count($schoolList//school)"/> schools in the file:<br/>
    <x:forEach select="$schoolList//school">
         <x:out select="name"/><br/>
    </x:forEach>it parses the following xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <schools>
         <school id="34033">
              <name>Tumwater Middle School</name>
              <district>Tumwater</district>
              <type>middle</type>
              <active>false</active>
         </school>
         <school id="17001">
              <name>Garfield High School</name>
              <district>Seattle</district>
              <type>high</type>
              <active>true</active>
         </school>
         <school id="00023">
              <name>Tigard High School</name>
              <district>Tigard-Tualatin</district>
              <type>high</type>
              <active>true</active>
         </school>
    </schools>and it outputs:
    There are 3 schools in the file:
    Tumwater Middle School
    Garfield High School
    Tigard High School-----------------------------------------
    The second snippet:
    <c:import url="/WEB-INF/config/schools2.xml" var="xml2" />
    <x:parse doc="${xml2}" var="schoolList2"/>
    There are <x:out select="count($schoolList2//school)"/> schools in the file:<br/>
    <x:forEach select="$schoolList2//school">
         <x:out select="name"/><br/>
    </x:forEach>parses this xml file (note the xml schema declarations):
    <?xml version="1.0" encoding="UTF-8"?>
    <schools xmlns="http://www.serenus.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.serenus.com schools.xsd">
         <school id="34033">
              <name>Tumwater Middle School</name>
              <district>Tumwater</district>
              <type>middle</type>
              <active>false</active>
         </school>
         <school id="17001">
              <name>Garfield High School</name>
              <district>Seattle</district>
              <type>high</type>
              <active>true</active>
         </school>
         <school id="00023">
              <name>Tigard High School</name>
              <district>Tigard-Tualatin</district>
              <type>high</type>
              <active>true</active>
         </school>
    </schools>and its output is:
    There are 0 schools in the file:That's it! No errors at all! I'm 100% certain the variable names, filenames, etc. are correct. I've looked everywhere for an existing answer to this problem, but I can't find one. Is this a known issue? Please help.
    -Ben

    Hi Ben,
    I got exactly the same problem and also could not find any solution.
    Did you find a way out for this problem meanwhile?
    Any help is welcome!

  • Error validating xml with xsd schema on JSDK 1.4

    Hi All,
    Asked to me do it a Web Service client in Java and validate its xml answer with an xsd file using 1.4 plataform.
    I googled and I saw many samples to 1.5 plataform, and few samples to 1.4, but anyway I tried to do what they asked to me.
    I got connect with service, got the response and so I went to validate that xml with an xsd file.
    But I got an error on that task. The error occurs in the following line
    "Schema schema = factory.getSchema();"
    Bellow my code
    final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
              final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
              final String schemaSource = "C:\\GetAuthorizationServiceOutput.xsd";
              final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();          
              factory.setNamespaceAware(true);
              factory.setValidating(true);
              try {
              factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
              factory.setAttribute(JAXP_SCHEMA_SOURCE,new File(source));
              catch (IllegalArgumentException x) {
                   System.out.println(x.getMessage());
    DocumentBuilder builder = null;
              Document document = null;
              try {
                   builder = factory.newDocumentBuilder();
                   document = builder.parse(new InputSource(new StringReader(ret.toString())));
              } catch (ParserConfigurationException e) {
                   e.printStackTrace();
              } catch (SAXException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              **Schema schema = factory.getSchema();**
              Validator validator = schema.newValidator();
              try {
                   validator.validate(new DOMSource(document));
              } catch (SAXException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
    and here is the exception :
    Caused by: java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.getSchema()Ljavax/xml/validation/Schema;
    Method onLinkClicked of interface wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = btBack, page = br.com.weev.finan.mkb_er.extranet.view.relations.RelationsDetails, path = 30:form:btBack.RelationsDetails$4, isVisible = true, isVersioned = true]] threw an exception
    wicket.WicketRuntimeException: Method onLinkClicked of interface wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = btBack, page = br.com.weev.finan.mkb_er.extranet.view.relations.RelationsDetails, path = 30:form:btBack.RelationsDetails$4, isVisible = true, isVersioned = true]] threw an exception
         at wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:198)
         at wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:74)
         at wicket.request.compound.DefaultEventProcessorStrategy.processEvents(DefaultEventProcessorStrategy.java:65)
         at wicket.request.compound.AbstractCompoundRequestCycleProcessor.processEvents(AbstractCompoundRequestCycleProcessor.java:57)
         at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:896)
         at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
         at wicket.RequestCycle.step(RequestCycle.java:1010)
         at wicket.RequestCycle.steps(RequestCycle.java:1084)
         at wicket.RequestCycle.request(RequestCycle.java:454)
         at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
         at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.GeneratedMethodAccessor342.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:187)
         ... 39 more
    Caused by: java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.getSchema()Ljavax/xml/validation/Schema;
         at br.com.weev.finan.mkb_er.business.manager.impl.RelationManagerImpl.getAuthorizationService(RelationManagerImpl.java:152)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
         at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy22.getAuthorizationService(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:377)
         at wicket.proxy.$Proxy39.getAuthorizationService(Unknown Source)
         at br.com.weev.finan.mkb_er.extranet.view.relations.RelationsDetails$4.onClick(RelationsDetails.java:125)
         at wicket.markup.html.link.Link.onLinkClicked(Link.java:254)
         ... 43 more
    It's my first time doing that, so I'm confuse to do it.
    Thank you
    Juliano.

    This is how.
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.validation.Schema;
    import javax.xml.validation.SchemaFactory;
    import javax.xml.validation.Validator;
    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
    dbfac.setNamespaceAware(true);
    SchemaFactory factory1 = SchemaFactory
                        .newInstance("http://www.w3.org/2001/XMLSchema");
    Schema schema = factory1.newSchema(new File("person.xsd"));
    dbfac.setSchema(schema);
    DocumentBuilder dbparser1 = dbfac.newDocumentBuilder();
    Document doc1 = dbparser1.parse(new File("person.xml"));
    Validator validator1 = schema.newValidator();
    DOMSource dm1 = new DOMSource(doc1);
    DOMResult domresult1 = new DOMResult();
    validator1.validate(dm1, domresult1);

  • Convert ResultSet - Xml with Xml Schema in java

    Hi
    I am using Web Services created in java and will be used from .Net client. Since its a cross platform, so I need to convert the Java ResultSet to XML stream (with schema) so that it could be accesed by .NET client. So I want to know how to convet a Java ResultSet into the desired xml stream (with schema).I know .NET provides this facility through some methods of DATASET.
    Will anybody tell me of any utility, tools or the methods so that I can accomplish this task.
    Thank in advance
    nitin

    I would think that the easiest way to do this would be to use web-services. Get the JWSDP. I don't think there is a direct way to go from ResultSet to XML. You'd have to write or find an external tool, though Oracle can create XML straight from the database.

  • Problems using XML DB with Schema

    Hi,
    I am attempting to use Java code running on WebLogic Server 10.3 to insert some XML documents into an Oracle Database (11gr1) and have them ‘shredded’ into columns, as the documentation claims is possible.
    I registered the XML Schema with Oracle using SQL*Plus, and have verified that tables and types are being built as expected. (Partial details below if needed.)
    I am able to insert records into the table, using XMLType, but they do not appear to be shredded in such a way that we can perform relational queries on them. References I found on the Oracle web site and others implied that if the XMLType is created with a schema associated, the insert will perform the shredding.
    When I attempt to create the XMLType with a schema in either of the two ways below, I get SQLExceptions.
    xml = XMLType.createXML(conn,doc.toString(), schema, true, true);
    Or
    xml = xml.createSchemaBasedXML(schema); // after a successful XMLType.createXML(conn, doc.toString());
    The most recent error is java.sql.SQLException: Fail to convert to internal representation (full stack trace along with the doc.toString() is below).
    How can I get more insight into what is causing this problem? Is there a more appropriate way to persist XML documents into Oracle relational tables? Is there some sample code/tutorial I can use that shows how to do this?
    Thank you,
    -=Alan
    --- Version of Oracle and validating that the schema is registered.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> describe objecthandle;
    Name Null? Type
    TABLE of SYS.XMLTYPE(XMLSchema "http://foo.org/mySchema" Element "ObjectHandle") STORAGE Object-relational TYPE
    "OBJECTHANDLE_TYPE"
    --- The XML document I am trying to persist.
    <ObjectHandle objectuid="objecthandle_301" serviceURL="URL-Fri Oct 31 17:47:19 EDT 2008" xmlns="http://foo.org/mySchema"/>
    --- The most recent error with full stack trace.
    java.sql.SQLException: Fail to convert to internal representation
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
    at oracle.sql.OPAQUE.<init>(OPAQUE.java:85)
    at oracle.xdb.XMLType.toDatum(XMLType.java:492)
    at oracle.jdbc.driver.OraclePreparedStatement.setORADataInternal(OraclePreparedStatement.java:7437)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8158)
    at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8149)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:229)
    at weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:314)
    at org.foo.test.Test.doInsert(Test.java:76)
    at org.foo.test.Test.testAddObjectHandle(Test.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at weblogic.wsee.component.pojo.JavaClassComponent.invoke(JavaClassComponent.java:112)
    at weblogic.wsee.ws.dispatch.server.ComponentHandler.handleRequest(ComponentHandler.java:84)
    at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:141)
    at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:114)
    at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
    at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
    at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
    at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:285)
    at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:169)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    Thanks - I have been fighting with another problem for the past few days, but am getting back to this now...
    I think the second link you sent helped me realize that the particular error came while using the 'thin' driver; I had other problems when I used the OCI driver... I'll try it again and see, now that I'm using a container managed datasource...
    I registered the schema in SQL*Plus using the command:
    BEGIN
    DBMS_XMLSCHEMA.registerURI(
    'http://foo.org/mySchema',
    '/home/foo/mySchema.xsd',
    LOCAL=>TRUE, GENTYPES=>TRUE, GENBEAN=>FALSE, GENTABLES=>TRUE);
    END;
    Everything created, was created from that command. I did use xdb annotations, but perhaps I didn't use enough of them...
    In this simple example (I have more complicated ones) there are only the two attributes; I've been hoping that I would be able to use normal sql statements, e.g.
    SELECT * FROM objecthandle WHERE objectuid='objecthandle_301';
    and get back either the XML or a resultset -- I'm less picky about that right now.
    I've been unable to find good reference material for this query; any advice will be appreciated.

  • Error in validating XML against schema

    Hi am getting some critical errors while Validating XML against schema
    error is:
    cvc-elt.1: Cannot find the declaration of element 'position' , here <position> is my root element.
    my code is as follows:
    package com.glemser.xmLabeling.library.component.spl;
    import com.documentum.com.DfClientX;
    import com.documentum.com.IDfClientX;
    import com.documentum.fc.client.IDfClient;
    import com.documentum.fc.client.IDfSession;
    import com.documentum.fc.client.IDfSessionManager;
    import com.glemser.common.helper.OperationHelper;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParserFactory;
    import java.io.CharArrayWriter;
    import java.io.IOException;
    import java.io.InputStream;
    public class Test {
    static IDfSession m_session;
    public static void main(String[] args) {
    try {
         new Test().validate();
    } catch (Exception e) {
    e.printStackTrace();
    private XMLReader xmlReader;
    private DefaultHandler handler; // Defines the handler for this parser
    private boolean valid = true;
    public void validate() {
    try {
    SetXML setXML = new SetXML();
    OperationHelper operation = new OperationHelper();
    String splObjPath = "C://Documents and Settings/dparikh/My Documents/xmLabelingStage/Test.xml";//operation.executeExportOperation(m_session, new DfId(m_objectId), true);
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(false);
    spf.setValidating(true);
    spf.setFeature("http://xml.org/sax/features/validation", true);
    spf.setFeature("http://apache.org/xml/features/validation/schema", true);
    spf.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
    if (spf.isValidating()) {
    System.out.println("The parser is validating");
    javax.xml.parsers.SAXParser sp = spf.newSAXParser();
    sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
    sp.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", "file://C:/Documents and Settings/dparikh/My Documents/xmLabelingStage/Test.xsd");
    System.out.println("The parser is validating1");
    //Create XMLReader
    xmlReader = sp.getXMLReader();
    xmlReader.setFeature("http://apache.org/xml/features/validation/schema", true);
    xmlReader.setEntityResolver(new SchemaLoader());
    ContentHandler cHandler = new MyDefaultHandler();
    ErrorHandler eHandler = new MyDefaultHandler();
    xmlReader.setContentHandler(cHandler);
    xmlReader.setErrorHandler(eHandler);
    System.out.println("The parser is validating2");
    parseDocument(splObjPath);
    } catch (SAXException se) {
    se.printStackTrace();
    } catch (ParserConfigurationException e) {
    e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    public void parseDocument(String xmlFile) {
    try {
    xmlReader.parse(xmlFile);
    if (valid) {
    System.out.println("Document is valid!");
    } catch (SAXException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    class MyDefaultHandler extends DefaultHandler {
    private CharArrayWriter buff = new CharArrayWriter();
    private String errMessage = "";
    /* With a handler class, just override the methods you need to use
    // Start Error Handler code here
    public void warning(SAXParseException e) {
    System.out.println("Warning Line " + e.getLineNumber() + ": " + e.getMessage() + "\n");
    public void error(SAXParseException e) {
    errMessage = new String("Error Line " + e.getLineNumber() + ": " + e.getMessage() + "\n");
    System.out.println(errMessage);
    valid = false;
    public void fatalError(SAXParseException e) {
    errMessage = new String("Error Line " + e.getLineNumber() + ": " + e.getMessage() + "\n");
    System.out.println(errMessage);
    valid = false;
    public class SchemaLoader implements EntityResolver {
    public static final String FILE_SCHEME = "file://";
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
    if (systemId.startsWith(FILE_SCHEME)) {
    String filename = systemId.substring(FILE_SCHEME.length());
    InputStream stream = SchemaLoader.class.getClassLoader().getResourceAsStream(filename);
    return new InputSource(stream);
    } else {
    return null;
    My XML and XSD are as below:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="position" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="position_number" type="xsd:string"/>
    <xsd:element name="position_title" type="xsd:string"/>
    <xsd:element name="report_to_position" type="xsd:string"/>
    <xsd:element name="incumbent" type="xsd:string"/>
    <xsd:element name="operation" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <position xsi:schemaLocation="Test.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <position_number>12345</position_number>
    <position_title>Sr. Engr</position_title>
    <report_to_position>23456</report_to_position>
    <incumbent>23456</incumbent>
    <operation>INSERT</operation>
    </position
    Please help me out

    --> Could not find cached enumeration value Custom.CI.Enum.PeripheralDevice.Printer for property Type, class BMC.Custom.CI.PeripheralDevice in enumeration cache.
    You must specify either the Name or Guid of an enumeration of type Custom.CI.Enum.PeripheralDevice.Type.
    Be sure that you are specifying the Name property of the enumeration value you want to set, and not the DisplayName; the Internal Name is something like "IncidentCategoryEnum.Category" for out of the box enumerations, or ENUM.210ADA2282FDABC3210ADA2282FDABC
    for enumerations created in the console.
    you can check this by finding the enumeration in the XML or by using the the
    SMLets commandlet
    Get-SCSMEnumeration | ?{$_.DisplayName –eq “Printer”}
    and then checking your value with
    Get-SCSMEnumeration -Name "ENUM.210ADA2282FDABC3210ADA2282FDABC"
    and see if you get the right displayname back

Maybe you are looking for