Validate xml with PL/SQL Parser

Hi,
i have an xml DTD into a VARCHAR2 variable and an xml document
into a CLOB, i'd like to know how to validate the xml with my
DTD using PL/SQL API for xml.
Sorry for my terrible english (i'm not english) :-)
Tank you.

Here's an example:
set serveroutput on
DECLARE
  p xmlparser.parser;
  d xmldom.DOMDocument;
  dtd xmldom.DOMDocumentType;
  v varchar2(32700);
  good clob;
  bad clob;
  xml_parse_error exception;
  pragma exception_init(xml_parse_error,-20100);
BEGIN
  bad   := '<!DOCTYPE Department SYSTEM "test.dtd"><Deprtment/>';
  good  := '<!DOCTYPE Department
SYSTEM "test.dtd"><Department/>';
  v := '<!ELEMENT Department EMPTY>';
  p := xmlparser.newParser;
  xmlparser.parseDTDBuffer(p,v,'Department');
  xmlparser.setDoctype(p,xmlparser.getDoctype(p));
  xmlparser.setValidationMode(p,TRUE);
  xmlparser.parseClob(p,good);
  xmlparser.parseClob(p,bad);
  xmlparser.freeParser (p);
EXCEPTION
  WHEN xml_parse_error THEN
     DBMS_OUTPUT.PUT_LINE(sqlerrm);
     xmlparser.freeParser (p);
END;

Similar Messages

  • Validating XML with PL/SQL parser

    How can i validate a xml that is on a buffer with the grammar
    stored in a BLOB column of o table? I'm using PL/SQL parser and
    i can parse it correctly but i don't know how can i validate it
    because my grammar is stored in DB.
    null

    Ana Lucia (guest) wrote:
    : How can i validate a xml that is on a buffer with the grammar
    : stored in a BLOB column of o table? I'm using PL/SQL parser
    and
    : i can parse it correctly but i don't know how can i validate
    it
    : because my grammar is stored in DB.
    You can't currently but this will be available in our next
    release.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • 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.

  • Parsing the xml with out dom parser in Oracle10g

    Hi,
    I need to parse the xml and create new xml with out any parsers in oracle 10g.Please help me how to do this one.

    Parsing without a parser eh? Could be tricky. Maybe if you go to the XML DB forum and explain your problem over there someone can help you...
    XML DB forum FAQ:
    XML DB FAQ

  • Validate XML with Schema?

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

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

  • Validate xml with complextype schema without root element!

    Hi All!
    I have a problem that. I want to validate a xml data of complextype but the schema i want to validate is[b] not have root element.
    For example:
    The schema like that
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="www.thachpn.test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="www.thachpn.test" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:complexType name="Name">
              <xs:sequence>
                   <xs:element name="FirstName" type="xs:string"/>
                   <xs:element name="LastName" type="xs:string"/>
              </xs:sequence>
         </xs:complexType>
    </xs:schema>
    and the xml data i want to validate like this
    <?xml version="1.0" encoding="UTF-8"?>
    <Name xmlns="www.thachpn.test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <FirstName>Pham</FirstName>
         <LastName>Thach</LastName>
    </Name>
    My Algorithm is like that:
    I create a complextype object by above schema
    then i create new element with given name and namespace
    after that i use schema of this element to validate xml data.
    I use xmlparserv2 lib of oracle
    But i can not find how to create complextype from schema or create element with have complextype.
    Please help me.
    Thanks a lot!

    <?xml version="1.0" encoding="UTF-8"?>
    Modify the schema.
    Add a root element.
    <xs:schema targetNamespace="www.thachpn.test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="www.thachpn.test" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xsd:element name="Name" type="Name"/>
    <xs:complexType name="Name">
    <xs:sequence>
    <xs:element name="FirstName" type="xs:string"/>
    <xs:element name="LastName" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>

  • Create XML with PL/SQL

    Hi,
    What is the best way to create large XML in pl/sql?? and to read large XML from CLOB procedure parameter?????
    Thanks

    Use the internal XML-structures of the database, such as XMLType, XMLElement, XMLForrest. Have a look at the XMLDB-documentation.

  • Xml and PL/SQL Parser problem.........

    While executing the sample procedure for XML/PLSQL Parser it gives the error:
    ERROR at line 1:
    ORA-29541: class SCOTT.oracle/xml/parser/plsql/XMLParserCover could not be resolved
    ORA-06512: at "SCOTT.XMLPARSERCOVER", line 0
    ORA-06512: at "SCOTT.XMLPARSER", line 57
    ORA-06512: at "SCOTT.DOMSAMPLE", line 57
    ORA-06512: at line 1
    While loading the xmlparserv2.jar by using Loadjava I got the resolving problem for some class.
    Wht should i do to rectify this error?
    Thanks And Regards
    Suresh
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
    SELECT TEXT FROM USER_ERRORS
    WHERE NAME = DBMS_JAVA.SHORTNAME('oracle/xml/parser/plsql/XMLParserCover')
    to see what error is preventing this class from being resolved...<HR></BLOCKQUOTE>
    ========================
    Hello.
    I have exactly the same problem and the above SQL does not return any rows.
    I upgraded my 8.1.5 on NT to 8.1.6. On trying to install the PL/SQL XML parser, received errors with resolving classes. Suspecting problems with Java VM, I re-installed the JVM using initjvm.sql. On successfull completion, i re-tried installing the parser. Still have the same problems.
    Is there anything else i could try?
    regards
    Krishnan.
    null

  • Validate XML with XSD

    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    with the partitioning, real application clusters, olap, data mining
    and Real Application Testing options
    Working with relational tables containing clob type columns (no XMLDB available) I'm not able to set up a simple validation example as below (supposed to return 1 confirming a successful validation).
    declare
      xmldoc xmltype;
      sb_xml xmltype;
      valid_ number;
      xmlxsd varchar2(4000) := q'~<?xml version="1.0" ?>
                                  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
                                  <xs:element name="greeting" type="xs:string" />
                                  </xs:schema>~';
      xmlxml varchar2(32767) := q'~<?xml version="1.0" ?><greeting>"HELLO !"</greeting>~';
    begin
      xmldoc := xmltype(xmlxml);
      sb_xml := xmldoc.createschemabasedxml();
      valid_ := sb_xml.isschemavalid(xmlxsd);
      dbms_output.put_line('IsSchemaValid (0=false,1=true): ' || to_char(valid_));
    end;Thanks in advance for any kind of help provided
    Etbin

    no XMLDB availablenot sure if it will work without xmldb, but you might try to use java for schema validation:
    SQL> CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "SchemaUtil"
      2  as
      3
      4  import oracle.xml.parser.schema.*;
      5  import oracle.xml.parser.v2.*;
      6  import oracle.sql.CHAR;
      7  import java.io.*;
      8
      9  public class SchemaUtil
    10  {
    11     public static String validation(CHAR xml, CHAR xsd)
    12     throws Exception
    13     {
    14        //Build Schema Object
    15        XSDBuilder builder = new XSDBuilder();
    16        byte [] docbytes = xsd.getBytes();
    17        ByteArrayInputStream in = new   ByteArrayInputStream(docbytes);
    18        XMLSchema schemadoc = (XMLSchema)builder.build(in,null);
    19        //Parse the input XML document with Schema Validation
    20        docbytes = xml.getBytes();
    21        in = new ByteArrayInputStream(docbytes);
    22        DOMParser dp  = new DOMParser();
    23        // Set Schema Object for Validation
    24        dp.setXMLSchema(schemadoc);
    25        dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    26        dp.setPreserveWhitespace (true);
    27        StringWriter sw = new StringWriter();
    28        dp.setErrorStream (new PrintWriter(sw));
    29        try
    30        {
    31           dp.parse (in);
    32           sw.write("The input XML parsed without errors.\n");
    33        }
    34        catch (XMLParseException pe)
    35        {
    36             sw.write("Parser Exception: " + pe.getMessage());
    37          }
    38        catch (Exception e)
    39          {
    40             sw.write("NonParserException: " + e.getMessage());
    41          }
    42          return sw.toString();
    43     }
    44   }
    45  /
    Java created.
    SQL>
    SQL> create or replace function schemavalidation(xml in varchar2,xsd in varchar2)
      2  return varchar2 is language java name 'SchemaUtil.validation(oracle.sql.CHAR,oracle.sql.CHAR)
      3                   returns java.lang.String';
      4  /
    Function created.
    SQL>
    SQL> select schemavalidation('<?xml version="1.0" ?><greeting>"HELLO !"</greeting>',
      2                           '<?xml version="1.0" ?>
      3                          <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      4                          <xs:element name="greeting" type="xs:string" />
      5                          </xs:schema>') schemavalidation from dual
      6  /
    SCHEMAVALIDATION
    The input XML parsed without errors.
    SQL>

  • XML with PL/SQL

    i want to generate the XML document in tree
    structure format by writing the Pl/sql

    Use the xmlgen.getXML package/proceure. This comes with the Oracle SQl Utility (I believe) tool.

  • Does anyone know why parsing with PL/SQL parser takes too long

    I am parsing a XML document ( 168 K )
    which it contains 300 Nodes and each node has 22 attributes, it
    takes 5 minuts using xmldom calls ( from PL/SQL XML parser )..
    When I cut that file in to 2 files ( 85 K or so ) it takes 1
    minute per file..
    Any ideas why ??????
    Thanks

    I am parsing a XML document ( 168 K )
    which it contains 300 Nodes and each node has 22 attributes, it
    takes 5 minuts using xmldom calls ( from PL/SQL XML parser )..
    When I cut that file in to 2 files ( 85 K or so ) it takes 1
    minute per file..
    Any ideas why ??????
    Thanks

  • Validate xml with local dtd

    hello
    trying to write a unit test that validates some xml we are marshalling against a dtd. here is a snippet of code. The problem is how to specify the dtd against which the xml is to be validated. verification_transaction is our root xml element. when i run this code i get a
    malformedurlexception: no protocol: verification.dtd
    any ideas?
                    StringWriter writer = new StringWriter();
                   // write the doctype declaration
                    writer.write("<!DOCTYPE verification_transaction SYSTEM \"verification.dtd\">");
                    // now marshal to the writer
              marshaller.marshal(spec, requestType, componentNumber, writer);
              InputStream inputStream = new ByteArrayInputStream(writer.getBuffer().toString().getBytes());
              Reader reader = new InputStreamReader(inputStream);
                    // get a sax parser that is validating
              TestHandler handler = new TestHandler();
              SAXParserFactory factory = SAXParserFactory.newInstance();
              factory.setValidating(true);
              SAXParser saxParser = factory.newSAXParser();
              try {
                   saxParser.parse(new InputSource(reader), handler);
                   fail("Should have thrown exception.");
              } catch (RuntimeException e) {
                   // pass
              }Message was edited by:
    shrndegruv

    I needed to do a bunch of things.
    1.
                    URL url = getClass().getResource("/verification.dtd");
              StringWriter writer = new StringWriter();
              writer.write("<?xml version=\"1.0\"?><!DOCTYPE verification_transaction SYSTEM \"" + url + "\">");and then I had to use a handler which processed the errors (which I got from an online tutorial):
    private static class MyErrorHandler extends DefaultHandler {
              public void warning(SAXParseException e) throws SAXException {
                   System.out.println("Warning: ");
                   printInfo(e);
              public void error(SAXParseException e) throws SAXException {
                   System.out.println("Error: ");
                   printInfo(e);
                   throw new SAXException("DTD Validation Error: [" + e.getMessage() + "]");
              public void fatalError(SAXParseException e) throws SAXException {
                   System.out.println("Fatal error: ");
                   printInfo(e);
              private void printInfo(SAXParseException e) {
                   System.out.println("   Public ID: " + e.getPublicId());
                   System.out.println("   System ID: " + e.getSystemId());
                   System.out.println("   Line number: " + e.getLineNumber());
                   System.out.println("   Column number: " + e.getColumnNumber());
                   System.out.println("   Message: " + e.getMessage());
         }

  • Validate xml with DOM - no grammar found

    Validation with XmlSpy is OK!
    Please help me. My problem is...
    ==========================================================
    // Schema...
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:complexType name="ParentType">
    <xs:sequence>
    <xs:element name="parent1" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ChildType">
    <xs:complexContent>
    <xs:extension base="ParentType">
    <xs:sequence>
    <xs:element name="child1" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    <xs:element name="root">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="element" type="ParentType" maxOccurs="2"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    ==========================================================
    // Xml-file:
    <?xml version="1.0" encoding="UTF-8"?>
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://pctoiv/etktoiv/Extending.xsd">
    <element xsi:type="ChildType">
    <parent1/>
    <child1/>
    </element>
    <element xsi:type="ParentType">
    <parent1/>
    </element>
    </root>
    =================================================================
    //java code...
    String W3C_XML_SCHEMA = "http://www.w3c.org/2001/XMLSchema";
    String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    String schemaSource = "http://pctoiv/etktoiv/Extending.xsd";
    javax.xml.parsers.DocumentBuilder documentBuilder = null;
    org.w3c.dom.Document xmlDoc = null;
    javax.xml.parsers.DocumentBuilderFactory docBuildFactory =
    javax.xml.parsers.DocumentBuilderFactory.newInstance();
    docBuildFactory.setNamespaceAware(true);
    docBuildFactory.setValidating(true);
    docBuildFactory.setAttribute(JAXP_SCHEMA_SOURCE, W3C_XML_SCHEMA);
    docBuildFactory.setAttribute( JAXP_SCHEMA_SOURCE, schemaSource);
    documentBuilder = docBuildFactory.newDocumentBuilder();
    documentBuilder.setErrorHandler(new MyErrorHandler(System.out));
    xmlDoc = documentBuilder.parse(new java.io.File("Extending.xml"));
    ================================================
    // And errors...
    org.xml.sax.SAXParseException: Document is invalid: no grammar found.
    org.xml.sax.SAXParseException: Document root element "root", must match DOCTYPE root "null".

    Validation with XmlSpy is OK!
    Please help me. My problem is...
    =======================================================
    ==
    // Schema...
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">
    <xs:complexType name="ParentType">
    <xs:sequence>
    <xs:element name="parent1" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ChildType">
    <xs:complexContent>
    <xs:extension base="ParentType">
    <xs:sequence>
    <xs:element name="child1" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    <xs:element name="root">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="element" type="ParentType"
    maxOccurs="2"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    =======================================================
    ==
    // Xml-file:
    <?xml version="1.0" encoding="UTF-8"?>
    <root
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://pctoiv/etktoiv/Ex
    ending.xsd">
    <element xsi:type="ChildType">
    <parent1/>
    <child1/>
    </element>
    <element xsi:type="ParentType">
    <parent1/>
    </element>
    </root>
    =======================================================
    =========
    //java code...
    String W3C_XML_SCHEMA =
    "http://www.w3c.org/2001/XMLSchema";
    String JAXP_SCHEMA_SOURCE =
    "http://java.sun.com/xml/jaxp/properties/schemaSource";
    String schemaSource =
    "http://pctoiv/etktoiv/Extending.xsd";
    javax.xml.parsers.DocumentBuilder documentBuilder =
    null;
    org.w3c.dom.Document xmlDoc = null;
    javax.xml.parsers.DocumentBuilderFactory
    docBuildFactory =
    javax.xml.parsers.DocumentBuilderFactory.newInstance();
    docBuildFactory.setNamespaceAware(true);
    docBuildFactory.setValidating(true);
    docBuildFactory.setAttribute(JAXP_SCHEMA_SOURCE,
    W3C_XML_SCHEMA);
    docBuildFactory.setAttribute( JAXP_SCHEMA_SOURCE,
    schemaSource);
    documentBuilder =
    docBuildFactory.newDocumentBuilder();
    documentBuilder.setErrorHandler(new
    MyErrorHandler(System.out));
    xmlDoc = documentBuilder.parse(new
    java.io.File("Extending.xml"));
    ================================================
    // And errors...
    org.xml.sax.SAXParseException: Document is invalid: no
    grammar found.
    org.xml.sax.SAXParseException: Document root element
    "root", must match DOCTYPE root "null".
    Try this:
    private static final String JAXP_SCHEMA_SOURCE
    = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    private static final String JAXP_SCHEMA_LANGUAGE
    = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    private static final String W3C_XML_SCHEMA
    = "http://www.w3.org/2001/XMLSchema";
    docBuildFactory.setNamespaceAware(true);
    docBuildFactory.setValidating(true);
    docBuildFactory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); // use LANGUAGE here instead of SOURCE
    docBuildFactory.setAttribute( JAXP_SCHEMA_SOURCE, schemaSource);
    documentBuilder = docBuildFactory.newDocumentBuilder();
    Good luck!
    Paul Niedenzu

  • Validate XML with XSD Puntuaction Marks

    Hello all,
    I am trying to validate a XML document against a registered XML schema. The XML document contains punctuation marks (like ã, ç, õ) which cause the validation to fail. How to overcome this?
    I suspect of the encoding format the XSD and XML documents are using, encoding=UTF-8, right?
    Thank you,
    Pedro.

    Ok... just needed to change the enconding attribute of the XML document to the value of the parameter NLS_CHARACTERSET of my database.
    Unnecessary post. :-o)

  • Validate XML with multiple XML Sechme in the same namespace

    In my program, i use multiple xml schemas to validate against my xml files.
    However, i found the following code do not work because all schemas in the same namespace.
    Does any one have some solutions to validate multiple XML Schemas in the same namespace?
    Thanks~~
    static final String[] schemas = { partyInformationSchema,
    itemInformationSchema,
    exceptionsSchema,
    salesForecastSchema,
    exceptionCriteriaSchema };
    factory.setAttribute(JAXP_SCHEMA_SOURCE, schemas);

    I have used the Object arrsy too, but it didn't work.
    static final Object[] schemas = { partyInformationSchema,
    itemInformationSchema,
    exceptionsSchema,
    salesForecastSchema,
    exceptionCriteriaSchema };

Maybe you are looking for

  • Events not synching from iPad to iMac in iCal.

    Events from my iPhone sych to my iMac just fine, but not my iPad2.  I use iCloud, and the settings on both devices are exactly the same.  Advice would be appreciated.  Thanks.

  • SAP CRM Structure for SearchHelpResult View of PRD01QR (Products)

    Hi All, I am unable to trace the underlying SAP structure name for SearchResult Node in GENIL_MODEL_BROWSER. I need the name of the structure, as i need to modify my Result View by adding another field to it for output display. Any input on this woul

  • Creating users thru GTC

    Hi, we are working on 2 OIM 9.1 machines, where we need to create users present in one OIM to other OIM instance through the use of SPML web services. not thru reconciliation. Host A contains an OIM server installed. A generic connector (GTC) is defi

  • Itunes only sync part of library

    For some reason my Ipod is only syncing to part of my Itunes library. I have over 750 songs in my library put when I sync only 64 songs are showing up. I have unistalled and reinstalled Itunes and have restored my Ipod to factory settings and still o

  • All my downloads have been erased or eliminated. How?

    Went online to retrieve a download and the entire download list was gone. I did not clear the list where did it go and can I retrieve it?