XML binary storage format impairs schema validation?

I'm using Oracle 11g R1 on Windows Server 2003. I successfully registered schemas and created tables and indexes in the new binary storage format. However, when trying to load data, I'm running into problems. Schema validation behaves as if not the full feature set of XML Schema mysteriously isn't supported anymore.
There is probably more but at least wildcard elements (xs:any) and element references (xs:element ref="STH") are simply ignored in the schema definition and data is rejected even when it conforms to the schema.
Is there any solution for this or am I out of luck? I wanted to go back to CLOB storage as used in a previous installation but I'm running into problems when registering the schema. It complains about an empty SQL name although I don't have any defined. I'm pretty weirded out by all this.
I created the schema and table in a straightforward way:
begin
  dbms_xmlschema.registeruri(
    schemaurl => 'http://www.xxxhello.com/archive_tsd.xsd',
    schemadocuri => '/public/user/archive_tsd.xsd',
    gentypes => FALSE,
    options => DBMS_XMLSCHEMA.REGISTER_BINARYXML
end;
CREATE TABLE archive OF xmltype XMLTYPE STORE AS binary xml XMLSCHEMA
"http://www.xxxhello.com/archive_tsd.xsd" ELEMENT "CompleteDocument";
create index idx_lastmodified_archive on archive t
(extractvalue(VALUE(t),'/CompleteDocument/DocContent/LastModified'));Because of xs:any or element references is ignored, I get errors like
LSX-00213: only 0 occurrences of particle "REFDELEM", minimum is 1.
Thanks for your help.

The schema is very large (>200kb). Where should I upload it or can I send it to you? I'm bit concerned about confidentiality of company data. However, the instance is not valid yet. I'm in the process of modifying the schema to match all instances, but it breaks on places that should be already okay. No, I didn't use SchemaValidate ever.
But I've made an example where at least xs:any doesn't work. Element references work, though.
Sample schema:
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema
  xmlns:tsd = "http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition"
  xmlns:xs = "http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <tsd:schemaInfo name = "sbreak">
        <tsd:collection name = "sbreak"></tsd:collection>
        <tsd:doctype name = "CompleteDocument">
          <tsd:logical>
            <tsd:content>open</tsd:content>
            <tsd:systemGeneratedIdentity reuse = "false"></tsd:systemGeneratedIdentity>
          </tsd:logical>
        </tsd:doctype>
        <tsd:adminInfo>
          <tsd:server>4.4.1.1</tsd:server>
          <tsd:modified>2007-07-03T16:00:46.484+02:00</tsd:modified>
          <tsd:created>2007-07-03T15:29:04.968+02:00</tsd:created>
          <tsd:version>TSD4.4</tsd:version>
        </tsd:adminInfo>
      </tsd:schemaInfo>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name = "CompleteDocument">
    <xs:complexType>
      <xs:choice minOccurs = "0" maxOccurs = "unbounded">
        <xs:element name = "ComplexNormal">
          <xs:complexType>
            <xs:choice minOccurs = "0" maxOccurs = "unbounded">
              <xs:element name = "NormalElem1" type = "xs:string"></xs:element>
              <xs:element name = "NormalElem2" type = "xs:string"></xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>
        <xs:element name = "ComplexAny">
          <xs:complexType>
            <xs:choice minOccurs = "0" maxOccurs = "unbounded">
              <xs:any minOccurs = "0" maxOccurs = "unbounded"></xs:any>
            </xs:choice>
          </xs:complexType>
        </xs:element>
        <xs:element name = "ComplexRef">
          <xs:complexType>
            <xs:choice minOccurs = "0" maxOccurs = "unbounded">
              <xs:element ref = "RefdElem"></xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>
        <xs:element name = "LastModified" type = "xs:string"></xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name = "RefdElem">
    <xs:complexType>
      <xs:choice minOccurs = "0" maxOccurs = "unbounded">
        <xs:element name = "Elem1" type = "xs:string"></xs:element>
        <xs:element name = "Elem2" type = "xs:string"></xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>Sample instance:
<?xml version="1.0" encoding="UTF-8" ?>
<CompleteDocument>
     <ComplexNormal>
          <NormalElem1>Test1</NormalElem1>
          <NormalElem2>Test2</NormalElem2>
     </ComplexNormal>
     <ComplexAny>
          <AnyElem>Test3</AnyElem>
     </ComplexAny>
     <ComplexRef>
          <RefdElem>
               <Elem1>Test4</Elem1>
               <Elem2>Test5</Elem2>
          </RefdElem>
     </ComplexRef>
</CompleteDocument>Log of what I did. First I confirmed, that I could enter the instance using clob storage:
SQL> begin
  2    dbms_xmlschema.registeruri(
  3      schemaurl => 'http://www.xxxhello.com/sbreak_tsd.xsd',
  4      schemadocuri => '/public/sbreak_tsd.xsd'
  5    );
  6  end;
  7  /
PL/SQL-Prozedur erfolgreich abgeschlossen.
SQL> CREATE TABLE sbreak OF xmltype XMLTYPE STORE AS clob XMLSCHEMA
"http://www.xxxhello.com/sbreak_tsd.xsd" ELEMENT "CompleteDocument";
Tabelle wurde erstellt.
SQL> create index idx_lastmodified_sbreak on sbreak t (extractvalue(VALUE(t),
'/CompleteDocument/LastModified'));
Index wurde erstellt.
SQL> insert into sbreak values(xmltype(bfilename('DATA', 'sbreak/sbreakinstance.xml'),
NLS_CHARSET_ID('AL32UTF8')));
1 Zeile wurde erstellt.Then I deleted table and schema again:
SQL> drop index idx_lastmodified_sbreak;
Index wurde gelöscht.
SQL> drop table sbreak;
Tabelle wurde gelöscht.
SQL> begin
  2    dbms_xmlschema.deleteschema(
  3      schemaurl => 'http://www.xxxhello.com/sbreak_tsd.xsd'
  4     ,delete_option => dbms_xmlschema.delete_cascade_force
  5    );
  6  end;
  7  /
PL/SQL-Prozedur erfolgreich abgeschlossen.After that I created schema and table with binary XML storage and tried to insert the same instance again:
SQL> begin
  2    dbms_xmlschema.registeruri(
  3      schemaurl => 'http://www.xxxhello.com/sbreak_tsd.xsd',
  4      schemadocuri => '/public/sbreak_tsd.xsd',
  5      gentypes => FALSE,
  6      options => DBMS_XMLSCHEMA.REGISTER_BINARYXML
  7    );
  8  end;
  9  /
PL/SQL-Prozedur erfolgreich abgeschlossen.
SQL> CREATE TABLE sbreak OF xmltype XMLTYPE STORE AS binary xml XMLSCHEMA
"http://www.xxxhello.com/sbreak_tsd.xsd" ELEMENT "CompleteDocument";
Tabelle wurde erstellt.
SQL> create index idx_lastmodified_sbreak on sbreak t (extractvalue(VALUE(t),
'/CompleteDocument/LastModified'));
Index wurde erstellt.
SQL> insert into sbreak values(xmltype(bfilename('DATA', 'sbreak/sbreakinstance.xml'),
NLS_CHARSET_ID('AL32UTF8')));
insert into sbreak values(xmltype(bfilename('DATA', 'sbreak/sbreakinstance.xml'),
NLS_CHARSET_ID('AL32UTF8')))
FEHLER in Zeile 1:
ORA-31011: XML-Parsing nicht erfolgreich
ORA-19202: Fehler bei XML-Verarbeitung
LSX-00021: undefined element "AnyElem"
aufgetretenSorry about the non-english text, but I think it can be guessed easily what's going on. Next I'll try a modifed schema without the tsd namespace added by the schema editor I use (the original large schema has been migrated from the Tamino XML database).

Similar Messages

  • Regarding schema validation and dbms_xmlparser, dbms_xmldom

    Hi All,
    Recently I came across one scenario, where I need to register XSD and validate all incoming xml agaist registered XSD and then access its contents and process them as per business needs.
    To accomplish this:
    1. Simply I have registered XSD using registerschema+ .
    2. To validate xmls, used schemaValidate+ .
    3. Once this is done then to fetch value from xml, I used below statement:
    SELECT EXTRACTVALUE (COLUMN_VALUE, '/details/emp_id') "Employee_ID"
    FROM TABLE
    +(XMLSEQUENCE+
    +(XMLTYPE+
    +('<?xml version="1.0"?>+
    +<employee>+
    +<details>+
    +<emp_id>1001</emp_id>+
    +</details>+
    +</employee>'+
    +).EXTRACT ('/employee/details')+
    +)+
    +) t;+
    This works fine.
    But I was browsing the same requirement over forum, got solutions related to DBMS_XMLPARSER and DBMS_XMLDOM.
    I tried to go through its details but didnt get much idea on the same.
    Can anyone please help me to understand about use of dbms_xmlparser and dbms_xmldom and about DOM.
    In which scenario we need to use them?
    Thanks
    Vikram

    Where I was thinking with that sentence is the "streaming evaluation" that Oracle now offers. This option is available when XML is stored in an XMLType column of SECUREFILE BINARY format (introduced in 11.1.0.6 and default for XMLType columns in 11.2.0.2) and that data is queried/accessed.
    You can find some information on it here
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb01int.htm
    (Search for "streaming")
    and here as well
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb_xquery.htm#CBAIIEFG
    Streaming is basically reading the data as Oracle scans past it since it knows, based on the binary storage format, what the XML looks like, so it does not need to create the whole document to find the sections the XPath/XQuery specifies. You can see that a SQL statement is using streaming evaluation when "XPATH EVALUATION" shows up in the explain plan as shown by
    {message:id=10737315}
    This option is only available when the XML is stored in the DB in the correct format. If the XML is stored in a PL/SQL variable, Oracle cannot use streaming evaluation on it.

  • Can schema validation be activated for a process instance?

    Is there some configuration property that can be added to the bpel.xml that will turn on schema validation for a single process (as opposed to turning this on for the entire engine)?
    Cheers,
    -Dustin

    Hi Dustin ,
    You can also use the same property in bpel deployment descriptor's partnerLinkBinding, to enable/disable xml validation for a particular partner. "validateXML" property in bpel dd will override the domain.xml's "validateXML" property.
    For example in LoanFlow/bpel.xml, enable validation for only StarLoanService partner:
    <partnerLinkBinding name="StarLoanService">
    <property name="wsdlLocation"> http://<hostname>:9700/orabpel/default/StarLoan/StarLoan?wsdl
    </property>
    <property name="validateXML">true</property>
    </partnerLinkBinding>
    HTH.
    Thanks,
    Rakesh

  • Schema validation for XMLType Clob vs Binary

    Hi
    Whilst looking at 11g R2 for use in validating XML against schemas, I have noticed that validation of XML using xmlDoc.schemavalidate() on a XMLType of CLOB would appear to be using a different schema validation process to validating by inserting into a column of XMLType of Binary.
    A couple of things that drew my attention to this is 1) the slight difference in error message format , and 2) the fact that the validation for the Binary XMLType was detecting an error with a date format whilst validation of the CLOB wasn't.
    Can anyone recommend which is the more thorough / robust of two ways to validate against a schema.
    Many Thanks
    Lawrence

    You'll find the {forum:id=34} forum the more appropriate location for this question. Include all 4 digits of your version and if possible a short script that shows the issue you found.
    Look in the [url https://wikis.oracle.com/display/Forums/Forums+FAQ]FAQ for how to use the tag to wrap your sample code and retain formatting when posting.  This would include how the schema is registered (I'm assuming you did at least).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • 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

  • Java Stored Procedure SAXParser XML Schema Validation

    Using Oracle XML Developers Kit 10.2.0.2.0 - Production.
    Attempting to validate using XML Schema in a Java stored procedure with the code:
                   if ( schemaDoc == null )
                        // Obtain default connection
                        Connection conn = new OracleDriver().defaultConnection();
                        OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement("SELECT XmlDocObj FROM XmlDoc WHERE XmlDocNbr = 2");
                        OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
                        if ( rset.next() )
                             // get the XMLType
                             XMLType schemaXml = (XMLType)rset.getObject(1);
                             XSDBuilder builder = new XSDBuilder();
                             XMLSchema schemaDoc = (XMLSchema)builder.build(new InputSource(schemaXml.getInputStream()));
                   if ( inst == null )
                        inst = new ValidateCoreRequest();
                   ErrorHandlerImpl handler = inst.getNewErrorHandler();
    SAXParser saxParser = new SAXParser();
    saxParser.setXMLSchema(schemaDoc);
    saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxParser.setErrorHandler(handler);
    saxParser.parse(new InputSource(new StringReader(docStr)));
    if( handler.validationError )
                        errorMsg[0] = handler.saxParseException.getMessage().substring(0, Math.min(199, handler.saxParseException.getMessage().length()));
    Never reports validation errors in the XML. Although the XDK Programmers Guide states "...you can use
    the oracle.xml.parser.schema.XSDBuilder class to build an XML schema and
    then configure the parser to use it by invoking the XMLParser.setXMLSchema()
    method. In this case, the XML parser automatically sets the validation mode to
    SCHEMA_STRICT_VALIDATION and ignores the schemaLocation and
    noNamespaceSchemaLocation attributes." No validation seems to occur. I have tried to set an xsi:noNamespaceSchemaLocation attribute on the root XML node, but this results in URL errors if the URL is not valid or schema build errors if the URL is valid, but does not point to a real location.
    It appears that without a schema location attribute, no schema validation occurs. Using setXMLSchema() with a database source does not seem to cause the schema location attributes to be ignored. At least for Java stored procedures.
    Does XML Schema validation work in the database for externally referenced schemas?
    Thank You,
    Art

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jan Vissers ([email protected]):
    I have two schemas A and B. A contains a java stored procedure which calls a java stored procedure stored in B. Upon resolving the "A" Java Stored Procedures I get the following error:
    ORA-29545: badly formed class: at offset 3093 of Adapter.TFADPBeschikbaarheid.sendAanvraag expecting a class-oracle.xml.parser.v2.XMLDocument but encountered a class-oracle.xml.parser.v2.XMLDocument.
    ... Question:
    it is expecting something which it has in fact encountered... SO!!!! What is the error.
    Thx,
    Jan<HR></BLOCKQUOTE>
    Try this:
    Edit your XSU installation script located on lib directory of Oracle XSU's distribution:
    Find the line:
    loadjava -r -v -u $USER_PASSWORD xmlparserv2.jar
    Replace by:
    loadjava -r -v -g public -u $USER_PASSWORD xmlparserv2.jar
    And installs your Oracle XSU again.
    Best regards, Marcelo.

  • JAXP API provides no way to enable XML Schema validation mode

    I am evaluating XDK 9.2.0.5.0 for Java and have encountered another
    problem with XML Schema support when using the JAXP API.
    Using the classes in oracle.xml.jaxp.*, it appears to be impossible to
    enable XML Schema validation mode. I can set the schema object, but
    the parser does not use it for validation.
    If I use DOMParser directly, I can call the setValidationMode(int)
    method to turn on schema validation mode. There is no equivalient
    means to enable XML Schema validation when using the JAXP API.
    Test case for JAXP API:
    === begin OracleJAXPSchemaTest.java ======
    package dfranklin;
    import java.io.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import oracle.xml.parser.schema.XMLSchema;
    import oracle.xml.parser.schema.XSDBuilder;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    public class OracleJAXPSchemaTest
    private final static String xsd = ""
    +"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"urn:dfranklin:test\">"
    +" <xsd:element name=\"amount\" type=\"xsd:integer\"/>"
    +"</xsd:schema>";
    private final static String xml =
    "<amount xmlns=\"urn:dfranklin:test\">1</amount>";
    public static void main(String[] args)
    throws Exception
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
              "oracle.xml.jaxp.JXDocumentBuilderFactory");
    new OracleJAXPSchemaTest().run();
    public void run()
    throws Exception
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setValidating(true);
    dbf.setNamespaceAware(true);
    XMLSchema xmlSchema = buildXMLSchema(new StringReader(xsd));
    dbf.setAttribute("oracle.xml.parser.XMLParser.SchemaObject",
              xmlSchema);
    DocumentBuilder docbldr = dbf.newDocumentBuilder();
    Document doc = docbldr.parse(new InputSource(new StringReader(xml)));
    print(doc);
    private XMLSchema buildXMLSchema(Reader xsdin)
    throws Exception
    XSDBuilder xsdBuilder = new XSDBuilder();
    XMLSchema xmlSchema = (XMLSchema)xsdBuilder.build(xsdin, null);
    return xmlSchema;
    private void print(Document doc)
    throws
    javax.xml.transform.TransformerConfigurationException,
    javax.xml.transform.TransformerException
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.transform(new DOMSource(doc), new StreamResult(System.out));
    System.out.println();
    === end OracleJAXPSchemaTest.java ======
    Running that program:
    java dfranklin.OracleJAXPSchemaTest
    produces this output
    Exception in thread "main" oracle.xml.parser.v2.XMLParseException: Element 'amount' used but not declared.
    at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:148)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:269)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
    at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:96)
    at dfranklin.OracleJAXPSchemaTest.run(OracleJAXPSchemaTest.java:40)
    at dfranklin.OracleJAXPSchemaTest.main(OracleJAXPSchemaTest.java:27)
    This shows that the parser is not using the XML Schema to validate the
    document. I think it's expecting to find a DTD.
    Here is the equivalent program using DOMParser directly, and setting
    validation mode to SCHEMA_VALIDATION.
    === begin OracleParserTest.java ====
    package dfranklin;
    import java.io.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import oracle.xml.parser.schema.XMLSchema;
    import oracle.xml.parser.schema.XSDBuilder;
    import oracle.xml.parser.v2.DOMParser;
    import oracle.xml.parser.v2.XMLParser;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    public class OracleParserTest
    private final static String xsd = ""
    +"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"urn:dfranklin:test\">"
    +" <xsd:element name=\"amount\" type=\"xsd:integer\"/>"
    +"</xsd:schema>";
    private final static String xml =
    "<amount xmlns=\"urn:dfranklin:test\">1</amount>";
    public static void main(String[] args)
    throws Exception
    new OracleParserTest().run();
    public void run()
    throws Exception
    DOMParser dp = new DOMParser();
    XMLSchema xmlSchema = buildXMLSchema(new StringReader(xsd));
    dp.setXMLSchema(xmlSchema);
    dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    dp.parse(new InputSource(new StringReader(xml)));
    Document doc = dp.getDocument();
    print(doc);
    private XMLSchema buildXMLSchema(Reader xsdin)
    throws Exception
    XSDBuilder xsdBuilder = new XSDBuilder();
    XMLSchema xmlSchema = (XMLSchema)xsdBuilder.build(xsdin, null);
    return xmlSchema;
    private void print(Document doc)
    throws
    javax.xml.transform.TransformerConfigurationException,
    javax.xml.transform.TransformerException
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.transform(new DOMSource(doc), new StreamResult(System.out));
    System.out.println();
    === end OracleParserTest.java ====
    Running that program
    java dfranklin.OracleParserTest
    produces this output
    <?xml version = '1.0'?>
    <amount xmlns="urn:dfranklin:test">1</amount>
    In this case, the parser has validated the document.
    I also tried this with version 10.1.0.0.0 beta, and got the same
    error.
    Darin Franklin

    Thanks for posting that. I tried that code and still got my problem. The big difference is that I'm reading a group of XML files each of which uses a large number of schema files. There are over 50 schema files organized so they can be included as needed. Each of the XML files has a noNamespaceSchemaLocation attribute specifying one of the ten top schma files, that includes many others.
    However, I did solve the problem. I added one line --
           saxb.setFeature( "http://apache.org/xml/features/validation/schema",
                    true);
            // next line is new
            saxb.setProperty( JAXPConstants.JAXP_SCHEMA_LANGUAGE,
                    JAXPConstants.W3C_XML_SCHEMA );after the setFeature to turn on schema validation.
    (It needs an import org.apache.xerces.jaxp.JAXPConstants; statement.)
    Note:With the feature set to true and the setProperty commented out, the EntityResolver is called at construction tiem, and for each schema file, but each element is flagged as needing to be declared.
    With the feature commented out, and the setProperty in place, the EntityResolver is not called, and there is no validation performed. (I added invalid content to one of the files and there were no errors listed.)
    With both the setFeature and the setProperty in place, however, I get the calls from the EntityResolver indicating that it is processing the schema files, and for the good files, I get no errror, but for the bad file, I get an error indicating a bad validation.
    Now I can make the EntityResolver quiet and get what I wanted. Maybe there are other ways to do this, but I've got one that works. :-)
    Thanks to all who have helped.
    Dave Patterson

  • Xml schema validation problem

    Hi All
    How to tackle this xml schema validation problem
    i am using the sample code provided by ORacle technet for xml
    schema validation in the Oracle database(817).
    The sample code works perfectly fine.
    Sample as provided by http://otn.oracle.com/tech/xml/xdk_sample/archive/xdksample_093001.zip.
    It works fine for normal xml files validated against
    xml schema (xsd)
    but in this case my validation is failing . Can you let me know why
    I have this main schema
    Comany.xsd
    ===========
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.company.org"
    xmlns="http://www.company.org"
    elementFormDefault="qualified">
    <xsd:include schemaLocation="Person.xsd"/>
    <xsd:include schemaLocation="Product.xsd"/>
    <xsd:element name="Company">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Person" type="PersonType" maxOccurs="unbounded"/>
    <xsd:element name="Product" type="ProductType" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    ================
    which includes the following 2 schemas
    Product.xsd
    ============
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:complexType name="ProductType">
    <xsd:sequence>
    <xsd:element name="Type" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    ==============
    Person.xsd
    ===========
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:complexType name="PersonType">
    <xsd:sequence>
    <xsd:element name="Name" type="xsd:string"/>
    <xsd:element name="SSN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    =================
    now when i try to validate a xml file against Company.xsd
    it throws an error saying unable to find Person.xsd.
    no protocol error
    Now where do i place these 2 schemas(.xsd files) Person & product
    so that the java schemavalidation program running inside Oracle
    database can locate these files
    Rgrds
    Sushant

    Hi Jinyu
    This is the java code loaded in the database using loadjava called by a wrapper oracle stored procedure
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import java.net.*;
    import java.io.*;
    import org.w3c.dom.*;
    import java.util.*;
    import oracle.sql.CHAR;
    import java.sql.SQLException;
    public class SchemaUtil
    public static String validation(CHAR xml, CHAR xsd)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    byte [] docbytes = xsd.getBytes();
    ByteArrayInputStream in = new ByteArrayInputStream(docbytes);
    XMLSchema schemadoc = (XMLSchema)builder.build(in,null);
    //Parse the input XML document with Schema Validation
    docbytes = xml.getBytes();
    in = new ByteArrayInputStream(docbytes);
    DOMParser dp = new DOMParser();
    // Set Schema Object for Validation
    dp.setXMLSchema(schemadoc);
    dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    dp.setPreserveWhitespace (true);
    StringWriter sw = new StringWriter();
    dp.setErrorStream (new PrintWriter(sw));
    try
    dp.parse (in);
    sw.write("The input XML parsed without errors.\n");
    catch (XMLParseException pe)
    sw.write("Parser Exception: " + pe.getMessage());
    catch (Exception e)
    sw.write("NonParserException: " + e.getMessage());
    return sw.toString();
    This is the code i used initially for validating a xml file against single xml schema (.xsd) file
    In the above code could u tell how to specify the second schema validation code for the incoming xml.
    say i create another Schemadoc for the 2nd xml schema.
    something like this with another parameter(CHAR xsd1) passing to the method
    byte [] docbytes1 = xsd1.getBytes();
    ByteArrayInputStream in1 = new ByteArrayInputStream(docbytes1);
    XMLSchema schemadoc1 = (XMLSchema)builder.build(in1,null);
    DOMParser dp = new DOMParser();
    How to set for the 2nd xml schema validation in the above code or can i combine 2 xml schemas.
    How to go about it
    Rgrds
    Sushant

  • Adapter Engine XML Schema Validation Error Surpression

    We recently developed a number of web services that are called by 3rd parties outside our network. The web service request once made is picked up by a Web Dispatcher which then forwards the request to the de-central adapter. Both of these components reside within within a DMZ.
    We have, as an additional security measure made use of the new Adapter Engine XML Schema validation available with PI 7.1, to ensure that the payload of incomming messages is checked to ensure that it is a known structure.
    Now here is my problem, we recently had these services penetration tested by a 3rd party to ensure that they were secure and whilst the report was very good showing no major weaknesses they did pickup on a couple of items including that the fact that if the XSD to be used during payload message validation cannot be found an 'ADAPTER.JAVA_EXCEPTION' is returned to the web service consumer that highlights the path details of where the XSD should be (but could not be found).
    This was viewed as useful to an attacker for a number of reasons:
    1. Feedback in SQL injection attempts via verbatim DB error messages greatly improves attacker efficiency
    2. Path information is useful to the attacker for OS fingerprinting, directory traversal attempts
    3. Other miscellaneous stack trace information is useful to an attacker to understand how the application works
    Is there anyway this can be surpressed so that the adapter does not show this information in the returned error message - see example message below ?
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: Schema MaintenanceOrderByIDQuery_sync.xsd not found in E:\usr\sap\DPI\DVEBMGS40\j2ee\cluster\server0\validation\schema\f7cd3b50a87411e08830ed9d0af006a5\urnstw.contractor.wfm.workorderretrieval\MaintenanceOrderByIDQueryRequest_Out\httpsap.comxiSAPGlobal20~Global\MaintenanceOrderByIDQuery_sync.xsd  (validation\schema)
         at com.sap.aii.adapter.soap.ejb.XISOAPAdapterBean.process(XISOAPAdapterBean.java:1041)
         at sun.reflect.GeneratedMethodAccessor497.invoke(Unknown Source)
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: Schema Schema1.xsd not found in E:\usr\sap\DPI\DVEBMGS40\j2ee\cluster\server0\validation\schema\f7cd3b50a87411e08830ed9d0af006a5\urnstw.contractor.wfm.workorderretrieval\MaintenanceOrderByIDQueryRequest_Out\httpsap.comxiEA-APPLSEGlobal\Schema1.xsd  (validation\schema)
         at com.sap.aii.adapter.soap.ejb.XISOAPAdapterBean.process(XISOAPAdapterBean.java:1041)

    Hi,
    We are having the same problem, so you are not alone.
    I had an extensive call with Azure premium support and we where able to determine that:
    - Nothing is missing or in the wrong place in my exported .xml file.
    - Any changes to the VNET's using the web gui interface of https://manage.windowsazure.com is not possible when you have dns servers and use an gateway
    - You can download the .xml configuration file of the network and make manual changes to it, then import it again , to add/remove dns servers and or subnet's. 
    I am currently waiting for an solution,  i have let them lower the urgency from A to B (because i can make changes trough xml) and responded to the next support contact (saying he will continue with the issue) that the problems seems to be with azure and
    he should speak with the previous person helping me.  I have not heard from Azure support since.
    SR Number:115021812414226
    Open on:02/18/2015 09:28
    > There are networks with and without gateways created and the issue is happening on all the networks.
    > We are unable to add or remove the DNS servers. (by web gui)
    > Also not able to add or remove any subnets. (by web gui)
    > Every time the error message is same but the DNS server name is different. (from another subnet then the one we are changing)
    > Created CRI- 3405931, but they said it will need WATS team.
    > Confirmed with WATS engineer as well and moving case to WATS.
    > Cx agreed to lower the severity of the case as they are able to make changes through the network configuration file.
    > But they still want to get this resolved soon.
    > Agreed and dropped off, reducing severity to B 24/7.
    I hope microsoft is going to resolve this soon, as i do not want to edit my xml for little things like adding a subnet all the time. I have requested an status update in the issue.
    Should anyone have more information on this, please share it here.

  • XML Schema validation Error

    Hi,
    Have a scenerio in which consecutive mapping needs to be done.The first mapping is a Java Mapping in which XML schema validation needs to be done.
    If XML Schema validation is sucessful(Mapping 1),then graphical message mapping(MM_Entry) needs to be performed.
    I have uploded a jar file in imported Archives which contains
    1)Schema file(inputSchema.xsd): This is an XSD file which is generated in XI....XSD fomat of Source message type
    2) The java Class file
    Following are few lines of code for better idea:
    public class SAXParser implements StreamTransformation {
    public void execute(InputStream input, OutputStream output) throws StreamTransformationException {
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    InputStream mySchema = this.getClass().getClassLoader().getResourceAsStream("inputSchema.xsd");
    SAXParser saxParser = saxParserFactory.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",mySchema);
    saxParser.parse(input, new HandlerBase());
    After above step(parsing),input is copied to output and streams are closed as follows:
    byte[] buf = new byte[4096];
    for(int len=-1;(len=input.read(buf))!=-1;)
    output.write(buf,0,len);
    input.close();
    output.close();
    After sending correct source message from input ,i am getting following error:
    Runtime exception occurred during execution of application mapping program com/sap/xi/tf/_MM_Entry_: com.sap.aii.utilxi.misc.api.BaseRuntimeException; Parsing an empty source. Root element expected!

    Daniel,
    As I've said, I've used it successfully in PI 7.0 SP10.
    You're right about documentation, it says that by default, Java 1.4.2 mark() and reset() methods of InputStream class are not fully implemented (mark() would do nothing and reset() would always throw an IOException). And that would be the expected behavior...
    ...unless the SAP developers have extended the InputStream class to include actual implementatios to the mark() and reset() methods.
    I'm not saying that they have, but it would be possible, wouldn't it?
    It does work, after all...
    Regards,
    Henrique.

  • XML Schema validation error in network configuration. Missing DnsRef

    When ever we try to make changes to a Virtual network we receive
    XML Schema validation
    error in network configuration. Missing DnsRef
    We can't make any changes to the Virtual network.
    The DNS ref exists as well.
    Considering exporting network config and re-importing however we have a lot of networks configured and want to be sure this is the correct way to proceed.
    Any feedback much appreciated.
    Thanks

    Hi,
    We are having the same problem, so you are not alone.
    I had an extensive call with Azure premium support and we where able to determine that:
    - Nothing is missing or in the wrong place in my exported .xml file.
    - Any changes to the VNET's using the web gui interface of https://manage.windowsazure.com is not possible when you have dns servers and use an gateway
    - You can download the .xml configuration file of the network and make manual changes to it, then import it again , to add/remove dns servers and or subnet's. 
    I am currently waiting for an solution,  i have let them lower the urgency from A to B (because i can make changes trough xml) and responded to the next support contact (saying he will continue with the issue) that the problems seems to be with azure and
    he should speak with the previous person helping me.  I have not heard from Azure support since.
    SR Number:115021812414226
    Open on:02/18/2015 09:28
    > There are networks with and without gateways created and the issue is happening on all the networks.
    > We are unable to add or remove the DNS servers. (by web gui)
    > Also not able to add or remove any subnets. (by web gui)
    > Every time the error message is same but the DNS server name is different. (from another subnet then the one we are changing)
    > Created CRI- 3405931, but they said it will need WATS team.
    > Confirmed with WATS engineer as well and moving case to WATS.
    > Cx agreed to lower the severity of the case as they are able to make changes through the network configuration file.
    > But they still want to get this resolved soon.
    > Agreed and dropped off, reducing severity to B 24/7.
    I hope microsoft is going to resolve this soon, as i do not want to edit my xml for little things like adding a subnet all the time. I have requested an status update in the issue.
    Should anyone have more information on this, please share it here.

  • XDK 9.2.0.2.0  XML Schema Validation within Oracle 8i database

    I am little confused on this forum regarding my problem to find out the possibility of XML Schema Validation using SAX Parser within Oracle 8.1.7 database java stored procedures.
    Right know I am trying to find out if it is possible to make XML Schema Validation using SAX parser within Oracle 8.1.7 java stored procedures using (loading) new Oracle 9i Rel 2 XDK jar files into database.
    Thanks

    I am little confused on this forum regarding my problem to find out the possibility of XML Schema Validation using SAX Parser within Oracle 8.1.7 database java stored procedures.
    Right know I am trying to find out if it is possible to make XML Schema Validation using SAX parser within Oracle 8.1.7 java stored procedures using (loading) new Oracle 9i Rel 2 XDK jar files into database.
    Thanks

  • How does XML DB handle XML Schema Validation ?

    In order to validate an XML document against an XML Schema using Oracle XML DB the XML Schema must first be registered with XML DB using the method registerSchema provided by the package DBMS_XMLSCHEMA.
    XDB provides two types of schema validation, 'Lax' Validation and 'Strict' Validation.
    'Lax' validation takes place whenever a schema based document is converted from it's textual representation into the XML DB internal object model. Errors caught by this validation will be prefixed with 'ORA'.
    'Stict' validation takes place when the XMLType methods schemaValidate() or isSchemaValid() are invoked.
    The schemaValidate() method throws an exception with an error message indicating what is wrong it encounteres an invalid document. The error message associated with the exception will be prefixed with LSX.
    The isSchemaValid() method returns true or false, depending on whether or not the document is valid. It cannot return any information about why the document is invalid.
    The reason for having both the Lax and Strict validation models is that Strict validation is much more expensive in terms of CPU and memory usage than Lax validation.

    Here are some examples of what is caught by Lax validation (ORA errors) and what is only caught by Strict validation (LSX errors).
    SQL> begin
      2     dbms_xmlschema.registerSchema('test',xmltype(
      3  '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.co
    eFormDefault="unqualified">
      4     <xs:complexType name="RootType">
      5             <xs:sequence>
      6                     <xs:element name="Mandatory"/>
      7                     <xs:element name="Enumeration">
      8                             <xs:simpleType>
      9                                     <xs:restriction base="xs:string">
    10                                             <xs:enumeration value="A"/>
    11                                             <xs:enumeration value="B"/>
    12                                             <xs:enumeration value="C"/>
    13                                     </xs:restriction>
    14                             </xs:simpleType>
    15                     </xs:element>
    16                     <xs:element name="MinLength">
    17                             <xs:simpleType>
    18                                     <xs:restriction base="xs:string">
    19                                             <xs:minLength value="4"/>
    20                                             <xs:maxLength value="20"/>
    21                                     </xs:restriction>
    22                             </xs:simpleType>
    23                     </xs:element>
    24                     <xs:element name="MaxLength">
    25                             <xs:simpleType>
    26                                     <xs:restriction base="xs:string">
    27                                             <xs:minLength value="1"/>
    28                                             <xs:maxLength value="4"/>
    29                                     </xs:restriction>
    30                             </xs:simpleType>
    31                     </xs:element>
    32                     <xs:element name="MaxOccurs" type="xs:string" maxOccurs="2"/>
    33                     <xs:element name="MinOccurs" minOccurs="2" maxOccurs="2"/>
    34                     <xs:element name="Optional" type="xs:string" minOccurs="0"/>
    35             </xs:sequence>
    36     </xs:complexType>
    37     <xs:element name="Root" type="RootType" xdb:defaultTable="ROOT_TABLE"/>
    38  </xs:schema>'));
    39  end;
    40  /
    PL/SQL procedure successfully completed.
    SQL> --
    SQL> -- Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    1 row created.
    SQL> --
    SQL> -- Undefined element 'Illegal'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Illegal>Hello World</Illegal>
      5     <Enumeration>A</Enumeration>
      6     <MinLength>ABCD</MinLength>
      7     <MaxLength>WXYZ</MaxLength>
      8     <MaxOccurs>1</MaxOccurs>
      9     <MaxOccurs>2</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30937: No schema definition for 'Illegal' (namespace '##local') in parent
    '/Root'
    SQL> --
    SQL> -- Multiple occurences of 'Optional'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (1) of 'Optional' XML node elements exceeded
    SQL> --
    SQL> -- Missing element 'Manadatory'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Enumeration>A</Enumeration>
      4     <MinLength>ABCD</MinLength>
      5     <MaxLength>WXYZ</MaxLength>
      6     <MaxOccurs>1</MaxOccurs>
      7     <MaxOccurs>2</MaxOccurs>
      8     <MinOccurs>1</MinOccurs>
      9     <MinOccurs>2</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> --
    SQL> -- Invalid Enumeration Value
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>Z</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31038: Invalid enumeration value: "Z"
    SQL> --
    SQL> -- MinLength Violation
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABC</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  --
    15  -- MaxLength Violation
    16  --
    17  /
    1 row created.
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>VWXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30951: Element or attribute at Xpath /Root/MaxLength exceeds maximum length
    SQL> --
    SQL> -- Missing element Optional - Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> --
    SQL> -- Too many instances of 'MaxOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MaxOccurs>3</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (2) of 'MaxOccurs' XML node elements exceeded
    SQL> --
    SQL> -- Too few instances of 'MinOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> create trigger validateSchema
      2  before insert on ROOT_TABLE
      3  for each row
      4  begin
      5     :new.object_value.schemaValidate();
      6  end;
      7  /
    Trigger created.
    SQL> --
    SQL> -- Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    1 row created.
    SQL> --
    SQL> -- Undefined element 'Illegal'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Illegal>Hello World</Illegal>
      5     <Enumeration>A</Enumeration>
      6     <MinLength>ABCD</MinLength>
      7     <MaxLength>WXYZ</MaxLength>
      8     <MaxOccurs>1</MaxOccurs>
      9     <MaxOccurs>2</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30937: No schema definition for 'Illegal' (namespace '##local') in parent
    '/Root'
    SQL> --
    SQL> -- Multiple occurences of 'Optional'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (1) of 'Optional' XML node elements exceeded
    SQL> --
    SQL> -- Missing element 'Manadatory'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Enumeration>A</Enumeration>
      4     <MinLength>ABCD</MinLength>
      5     <MaxLength>WXYZ</MaxLength>
      6     <MaxOccurs>1</MaxOccurs>
      7     <MaxOccurs>2</MaxOccurs>
      8     <MinOccurs>1</MinOccurs>
      9     <MinOccurs>2</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00213: only 0 occurrences of particle "Mandatory", minimum is 1
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at "XDBTEST.VALIDATESCHEMA", line 2
    ORA-04088: error during execution of trigger 'XDBTEST.VALIDATESCHEMA'
    SQL> --
    SQL> -- Invalid Enumeration Value
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>Z</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31038: Invalid enumeration value: "Z"
    SQL> --
    SQL> -- MinLength Violation
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABC</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  --
    15  -- MaxLength Violation
    16  --
    17  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00221: "ABC" is too short (minimum length is 4)
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at "XDBTEST.VALIDATESCHEMA", line 2
    ORA-04088: error during execution of trigger 'XDBTEST.VALIDATESCHEMA'
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>VWXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30951: Element or attribute at Xpath /Root/MaxLength exceeds maximum length
    SQL> --
    SQL> -- Missing element Optional - Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> --
    SQL> -- Too many instances of 'MaxOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MaxOccurs>3</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (2) of 'MaxOccurs' XML node elements exceeded
    SQL> --
    SQL> -- Too few instances of 'MinOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00213: only 1 occurrences of particle "MinOccurs", minimum is 2
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at "XDBTEST.VALIDATESCHEMA", line 2
    ORA-04088: error during execution of trigger 'XDBTEST.VALIDATESCHEMA'
    SQL>

  • XML Schema Validations in JDK1.4?

    Hi,
    The below code errors out when run on JDK1.4-          
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schemaXSD = schemaFactory.newSchema(new File("C:\\TestSchema.xsd"));
    Validator validator = schemaXSD.newValidator();
    SAXSource source = new SAXSource(new InputSource("D:\\test.xml"));
    validator.validate(source);
    The exception is-
    Exception Message=http://www.w3.org/2001/XMLSchema
    java.lang.IllegalArgumentException: http://www.w3.org/2001/XMLSchema
    at javax.xml.validation.SchemaFactory.newInstance(Unknown Source)
    I also tried by adding the JAR file xml-apis.jar. But, it gives the same Exception.
    The above code runs fine on JDK1.5 but the requirement of my project is to use only JDK1.4 and run it on UNIX platform.
    Is there any way that this can work with JDK1.4?
    Otherwise are there any other JAVA API in JDK1.4 for performing XML Schema Validations?
    Thanks,
    Tanu

    Thanks DrClap.
    Does that mean JDK1.4 does not have any inbuilt classes for Schema Validations?
    Which parser should I use?
    Thanks,
    Tanu

  • Switching ON validate xml(Schema Validation) in BPEL Console for AIAtesting

    While we were testing Oracle O2B pip, we have recently switched on schema validation by turning it on to 'Strict' so that we can Validate
    XML in BPEL Console. Earlier when we were testing we had turned the schema validation as 'None' on BPEL console, and hence everything was working fine and
    no errors we popping out while creating sales order in Siebel CRM. But the moment we put validate xml to ' Strict' it starts throwing validation errors.
    So can you please help us to know whether it is right to test the Oracle O2B pip by putting validate xml to 'Strict'? If it is fair to test it by switching
    ON Validate XML(putting validate xml to 'Strict') then we are getting below error.
    We are creating a new sales order in Siebel CRM and when we check in BPEL console it was faulted at UpdateSalesOrderSiebelCommsProvABCSImpl (v. 1.0) .When we checked the BPEL flow it is throwing error at InvokeUpdateUpsert.
    Error is According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.2.4.a: Invalid content was found starting with element 'xsdLocal1:Process_spcInstance_spcId'. One of '{"http://siebel.com/asi":Process_spcInstance_spcId}' is expected.
    Steps for Switching on Validation ?
    1)     Login to BPEL Console
    2)     Go To Configuration section
    3)     Schema Validation changes
    a.     ON: populate validateXML with value strict
    b.     OFF: populate validateXML with value none
    Really appreciate if you can help..

    hi
    Indeed, the "Validate XML" menu option only shows "Validate XML: 0 errors, 0 warnings.".
    But, if you look at the "Design" tab for your schema, the "invoices" element node contains an "xsd:invoice" sequence shown in red. If you change "xsd:invoice" to "invoice" this becomes white and the node can be expanded.
    One other thing, registering an XML Schema in JDeveloper like the one you posted, isn't possible without an "oracle.xml.parser.schema.XSDException" (without further details).
    regards
    Jan Vervecken

Maybe you are looking for