Validate xml fails using XInclude.

I tried to use the XInclude syntax in a very simple way in order to make my xml more modular.
Here the example :
<?xml version='1.0' encoding='windows-1252'?>
<frame name="pippo" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:schemaLocation="http://www.axioma.it/AXI Frames.xsd" xmlns="http://www.axioma.it/AXI">
<vo name="prova">
<xi:include href="Incluso.xml" parse="xml"/>
</vo>
</frame>
The validate Xlm fails with this error
Error(4,45): <Line 4, Column 45>: XML-24534: (Error) Element 'include' not expected.
How can avoid this ?
Did I forget something ?
Tks
Tullio

I'm quite new and I don't know exactly the syntax You are speaking about.
I just need to create an xml file, wich is validated by Frames.xsd, including in it some other xml fragments I need to reuse.
In my code I named 2 xmlspaces, my own and xi wich refers to include specification and I thought it was enough in order to use XInclude specification, is it wrong ?
How can I specify what I need ?
Tks
Tullio

Similar Messages

  • XSL to validate xml structure using XSD

    Hi,
    Can you please provide me a sample xsl that validates input XML against the given schema?
    I have been trying with the following, but I am getting an error in jdeveloper 11g.
    XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
    Process exited with exit code 1.
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import-schema schema-location="po1.xsd"/>
    <xsl:output method="xml" version="1.0" indent="yes"/>
    <!-- Root template -->
    <xsl:template match="/">
    <xsl:if test="not(* instance of schema-element(authorising))">
    <xsl:message terminate="yes">
    Source document is not a validated Provisioning list
    </xsl:message>
    </xsl:if>
    <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Thanks
    923344

    Hi,
    Can you please provide me a sample xsl that validates input XML against the given schema?
    I have been trying with the following, but I am getting an error in jdeveloper 11g.
    XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
    Process exited with exit code 1.
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import-schema schema-location="po1.xsd"/>
    <xsl:output method="xml" version="1.0" indent="yes"/>
    <!-- Root template -->
    <xsl:template match="/">
    <xsl:if test="not(* instance of schema-element(authorising))">
    <xsl:message terminate="yes">
    Source document is not a validated Provisioning list
    </xsl:message>
    </xsl:if>
    <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Thanks
    923344

  • Validate XML file using nested XSD's

    Hi,
    I am currently trying to create a method that can validate a XML document based on a long series of nested XSD's.
    I am however not sure of how to implement this validation with the nested XSD's.
    Currently I have created the following function:
         public void validate(InputStream xmlDocument) {
              try {
                   SAXParserFactory spf = SAXParserFactory.newInstance();
                   spf.setNamespaceAware(true);
                   spf.setValidating(true);
                   SAXParser sp = spf.newSAXParser();
                   InputStream schema1 = this.getClass().getResourceAsStream("schema.xsd");
                   InputStream schema2 = this.getClass().getResourceAsStream("schema1.xsd");
                   Object[] schemas = {schema1,schema2};
                   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 JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
                   sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   sp.setProperty(JAXP_SCHEMA_SOURCE, schemas);
                   sp.parse(xmlDocument, new ParseErrorHandler());
              } catch (SAXException e) {
                   System.out.println(e.toString());
              } catch (ParserConfigurationException e) {
                   System.out.println(e.toString());
              } catch (IOException e) {
                   System.out.println(e.toString());
    The schemas that I reference are imported into the namespace of the class that contains the above method. schema.xsd contains a reference to schema1.xsd.
    The exception that I get is:
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Generic Exception: -> com.sap.engine.lib.xml.util.NestedException: [location : null] ERROR : schema1.xsd (The system cannot find the file specified)
    This I dont understand since the schema1.xsd is located right along with schema.xsd which is found without trouble.
    Hope someone can clearify this issue for me, since I'm somewhat lost.
    Best regards,
    Daniel

    Hi,
    I am currently trying to create a method that can validate a XML document based on a long series of nested XSD's.
    I am however not sure of how to implement this validation with the nested XSD's.
    Currently I have created the following function:
         public void validate(InputStream xmlDocument) {
              try {
                   SAXParserFactory spf = SAXParserFactory.newInstance();
                   spf.setNamespaceAware(true);
                   spf.setValidating(true);
                   SAXParser sp = spf.newSAXParser();
                   InputStream schema1 = this.getClass().getResourceAsStream("schema.xsd");
                   InputStream schema2 = this.getClass().getResourceAsStream("schema1.xsd");
                   Object[] schemas = {schema1,schema2};
                   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 JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
                   sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   sp.setProperty(JAXP_SCHEMA_SOURCE, schemas);
                   sp.parse(xmlDocument, new ParseErrorHandler());
              } catch (SAXException e) {
                   System.out.println(e.toString());
              } catch (ParserConfigurationException e) {
                   System.out.println(e.toString());
              } catch (IOException e) {
                   System.out.println(e.toString());
    The schemas that I reference are imported into the namespace of the class that contains the above method. schema.xsd contains a reference to schema1.xsd.
    The exception that I get is:
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Generic Exception: -> com.sap.engine.lib.xml.util.NestedException: [location : null] ERROR : schema1.xsd (The system cannot find the file specified)
    This I dont understand since the schema1.xsd is located right along with schema.xsd which is found without trouble.
    Hope someone can clearify this issue for me, since I'm somewhat lost.
    Best regards,
    Daniel

  • How to validate XML files using several XSD?

    hi friends i need java code for this application >?
    Plz. help me urgent............

    Use the parser property
    http://apache.org/xml/properties/schema/external-schemaLocation
    to specify more than one schemas.
    http://xerces.apache.org/xerces2-j/properties.html

  • HOW TO USE isSchemaValid() in oracle 9i to validate XML against XSD

    Hi
    I am trying to validate xml file against xsd in oracle 9i.The steps are as follows:
    *1.Created directory for xml and xsd file location:*
    CREATE or replace DIRECTORY XML_DATA AS 'D:\prod\sample xml and xsd;
    *2.Register the schema*
    DECLARE
    bf5 BFILE;
    BEGIN
    -- Register the schema
    dbms_lob.filecloseall;
    bf5 := BFILENAME('XML_DATA','xml1.xsd');
    DBMS_XMLSCHEMA.registerSchema('http://www.example.com/schemas/ipo.xsd',bf5,TRUE, TRUE, FALSE,TRUE,TRUE);
    -- dbms_lob.fileclose(bf5);
    END;
    *3.creatibg table to store xml files*
    CREATE TABLE po_tab2 (id NUMBER,xmlcol SYS.XMLType) ;
    *4.Inserting xml file into the table and validating that file with xml schema*
    declare
    aa clob:=' ';
    b varchar2(4000);
    c xmltype;
    begin
    dbms_lob.filecloseall;
    aa:= GETCLOBDOCUMENT('XML_DATA','example.XML','WE8MSWIN1252');
    INSERT INTO po_tab2 (ID, XMLCOL)
    VALUES
    (104,sys.XMLType.createXML(aa));
    commit;
    --c:=sys.xmltype.createXml(aa);
    c:=xmltype(aa);
    b:=VerifyXML(c,'http://www.example.com/schemas/ipo.xsd');
    dbms_output.put_line(b);
    end;
    _5.VerifyXML function is:_
    create or replace
    function VerifyXML( xml xmltype, xmlSchema varchar2 ) return varchar2 AUTHID DEFINER is
    xmlURL varchar2(4000);
    begin
    select
    s.qual_schema_url into xmlURL
    from user_xml_schemas s
    where s.schema_url = xmlSchema;
    if xml.isSchemaValid(xmlURL,'ManageRolloutRegionNotification') =1 then
    return( 'Valid. The supplied XML complies with XSD '||xmlURL );
    else
    -- return null;
    return(sqlcode|| 'Failed. The supplied XML does not comply with XSD '||xmlURL );
    end if;
    exception when others then
    return(sqlcode);
    end;
    _6.PROBLEM:_
    the problem is the function is always returning 'Failed ' status even though I am giving the correct file.. Is there any method to find the reason for failure. These codes are working fine oracle 11g. currently i am working in 9i version 9.2.0.1.0. I

    Oracle 9iR2 is not supported anymore.
    Oracle 9.2.0.8 is in sustained support.
    Oracle 9.2.0.1 is not supported at all.
    Upgrade to 11gR2.
    Sybrand Bakker
    Senior Oracle DBA

  • How to validate xml using xsd

    Hi All
    please tell me how to validate xml using xsd
    regards

    Try using this link:
    = http://www.google.nl/search?q=XML+validate+oracle for instance or
    = use the search button on this forum and / or
    = read the FAQ on this (XML DB FAQ
    Thanks Eddie et all, for educating me via http://awads.net/wp/2006/11/14/barts-punishment-for-asking-dumb-questions (don't mind the URL , the info there is really useful)
    The following link on this site is just brilliant: http://www.albinoblacksheep.com/flash/posting.php
    Grz
    Marco
    Message was edited by:
    mgralike

  • I am wondering if there is a way to validate XML file without using .......

    I am wondering if there is a way to validate XML file without using the <!DOCTYPE... but pass in the location of the schema/DTD file as a parameter to a validating method?
    thanks

    None that I know of. The only thing close is to use the EntityResolver interface where you can modify the location of the DTD file before it's being loaded and parsed, but that requires a <!DOCTYPE ...> in the XML file.
    Good luck.

  • Validate XML against Xml Schema using JDBC (thin_driver)

    hi all,
    i have a table with a xmltype-column (XmlSchema Support) and i wonna load(and validate) xml-data( as String) in the xmltype-column.
    some thing like this :
    int count=1;
    String SQLTEXT=null;
    Statement stmt=null;
    ResultSet rs =null;
    //while(count<=1000)
    try
    stmt = connection.createStatement();
    rs = stmt.executeQuery("select SEQ_patxmlschema_ID.NEXTVAL from patxmlschema");
    if(rs.next())
    id =rs.getLong(1);
    System.out.println(id);
    stmt.close();
    stmt=null;
    rs.close();
    SQLTEXT = "INSERT INTO patxmlschema(id, patID, name, status, patInfo)"+
              "VALUES(?,?,?,?,XMLType(?))";
    pStmt = connection.prepareStatement(SQLTEXT);
    long patID = random.nextInt(30000);
    System.out.println("patId: "+ patID);
    String name = RandomStringUtils.random(6,true,false);
    System.out.println("lastname: "+ name);
    String firstname=RandomStringUtils.random(5,true,false);
    System.out.println("firstname: "+ firstname);
    String status=RandomStringUtils.random(8,true,false);
    System.out.println("status: "+ status);
    String street=RandomStringUtils.random(6,true,false);
    System.out.println("street: "+ street);
    String zip=RandomStringUtils.random(5,false,true);
    System.out.println("zip: "+ zip);
    String city=RandomStringUtils.random(6,true,false);
    System.out.println("city: "+ city);
    String phone=RandomStringUtils.random(8,false,true);
    String email=RandomStringUtils.random(15,true,false);
    String state=RandomStringUtils.random(6,true,false);
    String country=RandomStringUtils.random(6,true,false);
    System.out.println("country: "+ country);
    xmldoc=
         "<Patient>"+                    "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+          "xsi:noNamespaceSchemaLocation='http://olidong.net/patInfo.xsd'>"+
         "<Address>"+                         "<street>"+street+"</street>"+                         "<city>"+city+"</city>"+                    "<zip>"+zip+"</zip>"+
         "<state>"+state+"</state>"+                    "<country>"+country+"</country>"+
         "</Address>"+               "<phone>"+phone+"</phone>"+                    "<email>"+email+"</email>"+
         "</Patient>";
         pStmt.setLong(1, id);
         pStmt.setLong(2, patID);
         pStmt.setString(3, name);
         pStmt.setString(4, status);
         pStmt.setString(5, xmldoc);
         pStmt.executeUpdate();
    pStmt.close();
         pStmt=null;
         count++;
         //connection=null;
    catch(Exception e){
    e.printStackTrace();
    can you help me?
    Olidong

    hi Avi,
    my xml doc is valid. with the sqlplus the are no problem or error. tryng the same with jddbc(thin driver) i got this error.
    i don´t know, may be jdbc don´t support xml schema support insertion.
    i got this sample:
    DECLARE
    doc VARCHAR2(2000) :=
    '<schema
    targetNamespace="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
    xmlns:po="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <complexType name="PurchaseOrderType">
    <sequence>
    <element name="PONum" type="decimal"/>
    <element name="Company">
    <simpleType>
    <restriction base="string">
    <maxLength value="100"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Item" maxOccurs="1000">
    <complexType>
    <sequence>
    <element name="Part">
    <simpleType>
    <restriction base="string">
    <maxLength value="20"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Price" type="float"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    <element name="PurchaseOrder" type="po:PurchaseOrderType"/>
    </schema>';
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd', doc);
    END;
    CREATE TABLE mypurchaseorders OF XMLType
    XMLSchema "http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
    ELEMENT "PurchaseOrder"
    VARRAY xmldata."Item" STORE AS TABLE item_nested;
    INSERT INTO mypurchaseorders
    VALUES(
    XMLType(
    '<PurchaseOrder
    xmlns="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
    = "http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd
    http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd">
    <PONum>1001</PONum>
    <Company>IBM</Company>
    <Item>
    <Part>DB2 v9 Set</Part>
    <Price>2550</Price>
    </Item>
    <Item>
    <Part>8i Doc Set</Part>
    <Price>350</Price>
    </Item>
    </PurchaseOrder>'));
    with the sqlplus the are no error
    but insert with java jdbc:
    SQLTEXT = "INSERT INTO mypurchaseorders VALUES(XMLType(?))";
    String xmldoc= "<PurchaseOrder"+
    "xmlns='http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'" +
    "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
    "xsi:schemaLocation= 'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'"+
    "'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'>"+
    "<PONum>1001</PONum>"+
    "<Company>IBM</Company>"+
    "<Item> "+
    "<Part>DB2 v9 Set</Part>"+
    "<Price>2550</Price>"+
    "</Item>"+
    "<Item>"+
    "<Part>8i Doc Set</Part>"+
    "<Price>350</Price>"+
    "</Item>"+
    "</PurchaseOrder>";
    pStmt.setString(1, xmldoc);
    i got this error
    java.sql.SQLException: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00240: element-start tag is not well formed
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 301
    ORA-06512: at line 1
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
         at xml_tab.doInsert(xml_tab.java:118)
         at xml_tab.main(xml_tab.java:138)
    could you help me?
    Olidong

  • How to validate XML against XSD and parse/save in one step using SAXParser?

    How to validate XML against XSD and parse/save in one step using SAXParser?
    I currently have an XML file and XSD. The XML file specifies the location of the XSD. In Java code I create a SAXParser with parameters indicating that it needs to validate the XML. However, SAXParser.parse does not validate the XML, but it does call my handler functions which save the elements/attributes in memory as it is read. On the other hand, XMLReader.parse does validate the XML against the XSD, but does not save the document in memory.
    My code can call XMLReader.parse to validate the XML followed by SAXParser.parse to save the XML document in memory. But this sound inefficient. Besides, while a valid document is being parsed by XMLReader, it can be changed to be invalid and saved, and XMLReader.parse would be looking at the original file and would think that the file is OK, and then SAXParser.parse would parse the document without errors.
    <Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd" name="MyBook">
      <Chapter name="First Chapter"/>
      <Chapter name="Second Chapter">
        <Section number="1"/>
        <Section number="2"/>
      </Chapter>
    </Book>
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Book">
    <xs:complexType>
      <xs:sequence>
       <xs:element name="Chapter" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
         <xs:sequence>
          <xs:element name="Section" minOccurs="0" maxOccurs="unbounded">
           <xs:complexType>
            <xs:attribute name="xnumber"/>
          </xs:complexType>
          </xs:element>
         </xs:sequence>
         <xs:attribute name="name"/>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
      <xs:attribute name="name"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    public class SAXXMLParserTest
       public static void main(String[] args)
          try
             SAXParserFactory factory = SAXParserFactory.newInstance();
             factory.setNamespaceAware(true);
             factory.setValidating(true);
             SAXParser parser = factory.newSAXParser();
             parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                                "http://www.w3.org/2001/XMLSchema");
             BookHandler handler = new BookHandler();
             XMLReader reader = parser.getXMLReader();
             reader.setErrorHandler(handler);
             parser.parse("xmltest.dat", handler); // does not throw validation error
             Book book = handler.getBook();
             System.out.println(book);
             reader.parse("xmltest.dat"); // throws validation error because of 'xnumber' in the XSD
    public class Book extends Element
       private String name;
       private List<Chapter> chapters = new ArrayList<Chapter>();
       public Book(String name)
          this.name = name;
       public void addChapter(Chapter chapter)
          chapters.add(chapter);
       public String toString()
          StringBuilder builder = new StringBuilder();
          builder.append("<Book name=\"").append(name).append("\">\n");
          for (Chapter chapter: chapters)
             builder.append(chapter.toString());
          builder.append("</Book>\n");
          return builder.toString();
       public static class BookHandler extends DefaultHandler
          private Stack<Element> root = null;
          private Book book = null;
          public void startDocument()
             root = new Stack<Element>();
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
             if (qName.equals("Book"))
                String name = attributes.getValue("name");
                root.push(new Book(name));
             else if (qName.equals("Chapter"))
                String name = attributes.getValue("name");
                Chapter child = new Chapter(name);
                ((Book)root.peek()).addChapter(child);
                root.push(child);
             else if (qName.equals("Section"))
                Integer number = Integer.parseInt(attributes.getValue("number"));
                Section child = new Section(number);
                ((Chapter)root.peek()).addSection(child);
                root.push(child);
          public void endElement(String uri, String localName, String qName) throws SAXException
             Element finished = root.pop();
             if (root.size() == 0)
                book = (Book) finished;
          public Book getBook()
             return book;
          public void error(SAXParseException e)
             System.out.println(e.getMessage());
          public void fatalError(SAXParseException e)
             error(e);
          public void warning(SAXParseException e)
             error(e);
    public class Chapter extends Element
       public static class Section extends Element
          private Integer number;
          public Section(Integer number)
             this.number = number;
          public String toString()
             StringBuilder builder = new StringBuilder();
             builder.append("<Section number=\"").append(number).append("\"/>\n");
             return builder.toString();
       private String name;
       private List<Section> sections = null;
       public Chapter(String name)
          this.name = name;
       public void addSection(Section section)
          if (sections == null)
             sections = new ArrayList<Section>();
          sections.add(section);
       public String toString()
          StringBuilder builder = new StringBuilder();
          builder.append("<Chapter name=\"").append(name).append("\">\n");
          if (sections != null)
             for (Section section: sections)
                builder.append(section.toString());
          builder.append("</Chapter>\n");
          return builder.toString();
    }Edited by: sn72 on Oct 28, 2008 1:16 PM

    Have you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.

  • Validate XML using XSD (XML Schema)

    Hi experts.
    Is there any way in ABAP to validate XML file against specified XSD file?
    I found only possibility to validate against DTD, but no XSD. As far as I know this is only possible in Java, or is a part of XI. Is it doable without Java or XI (on NetWeaver 2004s)?
    Help appreciated (and rewarded).
    Regards, Frantisek.

    Hello
    Perhaps you missed this link: [How to Perform XML Validations in SAP NetWeaver Process Integration 7.1|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d06dff94-9913-2b10-6f82-9717d9f83df1]
    Regards
      Uwe

  • How to validate XML using java_xml_pack-summer-02?

    In jaxp1.1, we validate the xml file in this way:
    c:\java -jar Validator.jar myBookStore.xml
    However, in java_xml_pack-summer-02, which is latest version of jaxp, the Validator.jar is not available. So, how to validate xml file?
    Pls help.

    develop your own validator... here is a quick and dirty one, which spits exceptions when error are met:
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    public class Validator
      public static void main(String[] args) throws Exception {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setValidating(true);
        spf.setNamespaceAware(true);
        SAXParser sp = spf.newSAXParser();
        sp.parse(new File(args[0]), new DefaultHandler());
    }

  • Validating XML against an XML Schema using PL/SQL

    Hello everyone,
    I've a strange problem.
    I'm trying to validate an XMLTYPE variable against an XSD schema using the XMLisValid function.
    The XML I was trying to validate was returning false (0) when using this method.
    However, when I register the XSD against a column in a table and then insert this XMLTYPE into that column, I do not get any errors. If I change the XSD to ensure failure when using this method, I do get an error, so it is registered and working.
    I have then created a very basic XSD and both methods work when validating the XML against this. So obviously the more complicated XSD I want to validate against is making a difference, but I would expect them to either both fail or both pass, not one fail and one pass.
    Does anyone know why they'd be returning different results?
    Thanks in advance for your help.
    Robin
    examples of what I'm using:
    XML to validate:
    <centres>
    <add>
    <centre>
    <centreName>Name 1</centreName>
    <centreRef>45678</centreRef>
    </centre>
    </add>
    </centres>
    Simple XSD:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="centres" type="centresType"/>
    <xs:complexType name="addType">
    <xs:sequence>
    <xs:element type="xs:string" name="centreName"/>
    <xs:element type="xs:short" name="centreRef"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="centresType">
    <xs:sequence>
    <xs:element type="addType" name="add" maxOccurs="3" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    Complicated XSD:
    <?xml version="1.0" encoding="utf-8" ?>
    <!--Created with Liquid XML Studio - 30 Day Trial Edition 7.1.6.1440 (http://www.liquid-technologies.com)-->
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="centres">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="remove">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="centreRef">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="add">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="centre">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="centreName">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="centreRef">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element minOccurs="0" maxOccurs="1" name="qualifications">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="qualRef">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="modifyQualAssociations">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="remove">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="r">
    <xs:complexType>
    <xs:attribute name="centreRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="qualRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="add">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="a">
    <xs:complexType>
    <xs:attribute name="centreRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="qualRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    Steps to validate XML data against a schema in Oracle:
    1. Register your XSD in the database.
    begin
    dbms_xmlschema.registerschema(
    SchemaUrl,
    SchemaDoc,
    local => TRUE/FALSE);
    end;
    2. For validating your XML document against your registered schema, here is a sample pl/sql block.
    declare
    v_xml xmltype;
    begin
    v_xml := your_xml_document;
    v_xml.schemaValidate();
    end;
    Hope this helps :)

  • Validate XML record-by-record

    Hi,
    Our process receives XML files on a daily basis and the files are processed through Java.
    If a record in XML fails to validate against the XSD (i.e. schema validation error), the whole file gets rejected. The file gets loaded only after that record is corrected. That is the limitation of Java.
    But now we will now be processing the XML files through PL/SQL.
    I wanted to know whether the XML can be validated against the XSD record-by-record? Is it possible that only the record that fails to validate is rejected while the remaining records get loaded into the database?
    If so, could you please also suggest the correct approach?
    Thanks in advance.

    It should be possible but it will take some work because you only want/need to validate the XML starting from a given node against a XSD. Here's my thoughts on what it should take. I'm not sure what your XSD(s) look like so I'll make the following assumptions:
    Assumption:
    A XSD exists that can validate a single Customer.
    A XSD exists that can validate a single Program.
    The XML is syntactically valid to allow being created as a DOMDocument or XMLType
    You would need to load the full XML file into a DOMDocument or XMLType, both will work fine for parsing. I would lean towards XMLType as you can use XPaths to pull info from the XML. You will then need to pull out the Programs and Customers from main XML. For each Program/Customer, pull out the individual Program/Customer and validate that against the XSD. If it passes validation, continue processing that Program/Customer. If it fails validation, go on to the next Program/Customer and repeat the process.
    As I said, this approach only works if the XML is syntactically valid. If you can't load the file, you can't attempt to load the 99 Programs when the 1 Program is way off. If the XML is only invalid per the schema, then you can process as many Programs/Customers that are individually valid.
    Hope this helps. I'm sure other methods exist but this is what I could think of.

  • OSB Validate action failed validation

    Hi All,
    I'm trying to convert non-xml to xml by using XqueryTransformation source as an HL7 and target as an CCD schema.When validating the against the schema I got the following exception.
    Please provide any suggestions.
    <con:fault xmlns:con="http://www.bea.com/wli/sb/context">
    <con:errorCode>BEA-382505</con:errorCode>
    <con:reason>OSB Validate action failed validation</con:reason>
    <con:details>
    <con1:ValidationFailureDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
    <con1:message>
    string value '' does not match pattern for cs in namespace urn:hl7-org:v3
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    <con1:message>
    Element 'title@urn:hl7-org:v3' with empty content type cannot have text or element content.
    </con1:message>
    <con1:xmlLocation>
    <ns0:title xmlns:ns0="urn:hl7-org:v3">XXX</ns0:title>
    </con1:xmlLocation>
    </con1:ValidationFailureDetail>
    </con:details>
    Thanks
    Mani

    Hi Anuj,
    I tried doing that but in Response, it is echoing back the request after the statement:
    The invocation resulted in an error: .
    And now it shows:
    Stage Error Handler
    $fault: <con:fault xmlns:con="http://www.bea.com/wli/sb/context">
    <con:errorCode>BEA-382505</con:errorCode>
    <con:reason>OSB Validate action failed validation</con:reason>
    <con:details>
    <con1:ValidationFailureDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
    <con1:message>
    string value '2' is not a valid enumeration value for VersionType in namespace http://www.example.org/abcd_Request_Schema
    </con1:message>
    <con1:xmlLocation>
    <abcd:Version xmlns:abcd="http://www.example.org/abcd_Request_Schema">2</abcd:Version>
    </con1:xmlLocation>
    </con1:ValidationFailureDetail>
    </con:details>
    <con:location>
    <con:node>PipelinePairNode1</con:node>
    <con:pipeline>PipelinePairNode1_request</con:pipeline>
    <con:stage>request xml validation</con:stage>
    <con:path>request-pipeline</con:path>
    </con:location>
    </con:fault>
    System Error Handler
    $fault: <con:fault xmlns:con="http://www.bea.com/wli/sb/context">
    <con:errorCode>402</con:errorCode>
    <con:reason>
    Validation Failed. Please enter proper values.
    </con:reason>
    <con:details>
    <con1:ValidationFailureDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
    <con1:message>
    string value '2' is not a valid enumeration value for VersionType in namespace http://www.example.org/abcd_Request_Schema
    </con1:message>
    <con1:xmlLocation>
    <abcd:Version xmlns:abcd="http://www.example.org/abcd_Request_Schema">2</abcd:Version>
    </con1:xmlLocation>
    </con1:ValidationFailureDetail>
    </con:details>
    <con:location>
    <con:node>PipelinePairNode1</con:node>
    <con:pipeline>PipelinePairNode1_request</con:pipeline>
    <con:stage>request xml validation</con:stage>
    <con:path>request-pipeline</con:path>
    </con:location>
    </con:fault>
    Is there any way by which only the customized error can be seen & not the OSB errors?

  • Error while printing generated XML doc using DBMS_OUTPUT

    while generating XML document using XDK for PL/SQL i am getting " ORU-10027: buffer overflow, limit of 1000000 bytes " error even though i had set DBMS_OUTPUT to 1000000.
    Is there any way to getrid of this problem .
    i am using this code ..
    CREATE OR REPLACE procedure SQLToXML1 is
    queryCtx DBMS_XMLquery.ctxType;
    result CLOB;
    begin
    DBMS_OUTPUT.ENABLE (1000000);
    queryCtx := DBMS_XMLQuery.newContext ('select * from depolib_library' )
    result := DBMS_XMLQuery.getXML(queryCtx);
    printClobOut(result);
    DBMS_XMLQuery.closeContext(queryCtx);
    exception
    when others then
    dbms_output.put_line(sqlerrm);
    end;
    urgent help is needed
    Thanks
    null

    No, It is a PO Print only. Only for changes to PO that do not affect the value of the PO,this error occurs. When i select the entry for the PO and click on Output message, the output message fails. On clicking Display Message, it shows the message - No schedules exist for the Scheduling Agreement XXXXXX(the PO number".
    So,it is not for Scheduling Agreements but for PO only. I know it is weird to see such an error on the PO output message in ME9F.
    Pls help.

Maybe you are looking for

  • HT1694 How can I send videos via email (hotmail) that are 55 seconds or more?

    Hotmail is supposed to have a 10MB limit and my videos are only coming to 5MB. But I can send a video that is 54 seconds long, but 55 seconds won't send. I also tried sending it through a gmail account and it wouldn't work either. Any advice? I'm usi

  • How can i see flash videos with my iPad 2

    Hi , i need to know if apple fixed the problem with the flash videos

  • Urgent, please help-- connection does not close

    Hi, We are using Txdatasource, Oracle thin driver in WLS6.1 sp2. The problem we have is that we open connection and pass the connection as parameter to third part tool to generate report, but the tool doesn't close connection after finish, then the c

  • M130 HotSync issue with Vista

    In the process of installing Palm Desktop software version 6.2 for Vista on my laptop, when the wizard wanted to do the initial hotsync procedure I get the message on the Palm m130 that there is no connectivity between the Palm and my laptop via the

  • Regarding Transfer of HR data From SAP System to Non-SAP System

    Hi All, Can anyone Please help me how i can transfer HR Payroll Data from a SAP system to a Non-SAP system. If it can be done by using Bapi's Please send me some notes or code the way how it can be done,data can be transfered through IDOC wht wud be