Using XDK to Parse Schema

I'm having problems parsing an XSD file with xmlparserv2, and I suspect it's something simple I'm missing ...
Java Code:
DOMParser dp = new DOMParser();
dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
dp.setPreserveWhitespace (true);
dp.setErrorStream(System.err);
dp.parse(stream);
XMLDocument doc = dp.getDocument();
// works
Node n = doc.selectSingleNode("//*[@name='Transaction-850']", doc);
// ERR: oracle.xml.xpath.XPathException: Namespace prefix 'xsd' used but not declared
n = doc.selectSingleNode("//xsd:complexType", doc); //works
XSD File:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.edifecs.com/xdata/200" targetNamespace="http://www.edifecs.com/xdata/200" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0" elementFormDefault="qualified">
<xsd:element name="Transaction-850" type="Transaction-850"/>
<xsd:complexType name="Transaction-850">
<xsd:sequence>
<xsd:element name="Internal-Properties" type="Internal-Properties" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
I'm trying to integrate an XData XSD file into a mapping tool we have. The concept is to evaluate the XSD definition and generate a map.
I

It looks like the XDK is not using the document to resolve namespaces in this case. When I use the following NSResolver, the XPath expressions return nodes:
class NSResolverImpl implements NSResolver{
public String resolveNamespacePrefix(String prefix) {
String ns = null;
if(prefix.equals("xsd")) {
ns = "http://www.w3.org/2001/XMLSchema";
return ns;
It'd be nice to use the document itself to resolve namespaces defined therein as per Oracle examples. Is there something about the XData file that is lacking or is this an unsupported use case?

Similar Messages

  • Can multiple APEX application use the same parsing schema?

    Hi,
    I have 4.2 APEX thru pl/sql Gatewat, 11gr2 DB and using theme 24.
    Due to the APEX limitation for version control I would be splitting 1 big ERP applications into 24 different APEX applications and each application would be considered as 1 unit for version control.
    I have about 800 tables and I would assume that all of these would need to be stored in 1 schema since a lot of these table are linked thru FK.
    Can I have multiple APEX APPS using the same parsing schema? or is there a better way to do this?
    Thanks in advance!

    Hi,
    Multiple applications can have same (one) parsing schema.
    You can test that on e.g. apex.oracle.com, where normally you have only one schema and you create multiple applications and all use that same schema.
    Regards,
    Jari
    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai
    Edited by: jarola on Jan 28, 2013 7:15 PM

  • Problem with using JDom to parse Schema , help

    hi there
    I try to use samples downloaded from following URL to parse a schema stored on my hard drive
    http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-validation3_p.html
    the parseschema() method used in this sample uses SAX to read in the supplied schema URL and build a JDOM Document object. but I change it to read a string of "C:\\EBT Express\\shoes.xsd" and build a JDOM Document Object. but I got IOException saying that the file is not found. anyone out there familiar with JDOM, please help. can I use a string to replace URL?
    thank you.

    hi there
    thank you for your reply. I am just curious about how you run that sample code. when you supply a data to validate, how do you do it?

  • Choosing Different parsing schema

    Hi,
    I have 2 application using the one parsing schema (sch1)
    Now I want to create one another application, I would like to choose a different schema as parsing shcema (sch2),
    is this possible? it is not allowing me or it is not listing in the list box.

    Hi,
    Yes this is possible, you will need to assign schema sch2 to the workspace. You can do this in the APEX Admin app under Manage Workspaces 'Manager Workspace to Schema Assignments'. Then back in the Apex builder edit the Application definition and change the Parsing Schema to sch2.
    Regards
    Paul

  • Using XDKs XML Schema Parser

    I want to parse an XML schema(XSD file) and extract the types from it, ComplexType etc. Does anyone know to even begin this. Ive managed to parse and any XML file sucessfully returning all element types,names and values using the DOM parser but cant seem to find suitable methods in the oracle.xml.parser.schema library. I have started along these lines
    XSDBuilder bob =new XSDBuilder();
    XMLSchema sch = (XMLSchema)bob.build(url);
    where URL is string referencing the xsd file. But after that all I can get is the targetnamespace using
    String display = sch.getSchemaTargetNS();
    Any help greatly appreciated.

    Srinivas,
    Thanks for the reply. But that is not my requirement.Suppose I have a schema representing the following xml
    <Student>
    <Name>ABC</Name>
    <Class>XYZ</Class>
    <Course>PQR</Course>
    </Student>
    When I parse the XML Schema representing the above XML, it should give me a Java object that represents this XML structure. (Similar to Document object that is obtained when we an XML is parsed)
    Hope this is more clear.

  • How to parse XSD using XDK?

    Hi all,
    I'd appreciate to know how to parse a XML schema file. I realize that Oracle provides API as defined in:
    http://www.oracle.com/technology/tech/xml/xdk/doc/production/java/doc/java/javadoc/oracle/xml/parser/schema/XSDBuilder.html
    Are there any place I can get sample code or tutorial?
    Thanks!
    jason

    Hi Jason!
    I already used Oracle XML parser for parsing XML schema files, but I wouldn't recommend it!
    The classloader loads Oracle XDK classes first, so you can't use other XDK version then Application Server own XDK version.
    (This is a not yet solved classloader issue in application server.)
    I reallized, that Oracle sometimes change APIs in XDK, so sometimes it is no longer compatible with the old version API.
    If you develope a code that works in your Jdeveloper, perhaps it won't work on the application server and you won't have the option to use the appropriate XDK version.
    I recomend to use Xerces or other XML parser to parse XML schema files!
    http://xerces.apache.org/
    This way you can use any version of the XML parser in your application.

  • How to obtain the schema contents using XDK

    I have a requirement to access the entire schema - all elements, all simple types, complex types, annotations, etc. with the schema processor of the XDK in Java. I am wondering how to do this. All I get are the top level elements. I am not too sure how to browse each such entity. I cannot get things like hasChildren() and getChildren() (like in DOM tree nodes) in XSDNode or its implementations (XSDElement, XSDComplexType, etc). Could anyone help please?

    XMLSchema schema;
    Hashtable hashtable=schema.getXMLSchemaNodeTable();
    http://otn.oracle.com/tech/xml/xdk/doc/beta/doc/java/javadoc/oracle/xml/parser/schema/XMLSchemaNode.html

  • XML validation using XDK DOM/SAX Parser

    Hello,
    I am trying to validate xml against xsd using SAX/DOM parser, both the files are stored as CLOB column in the database. I have the requirement to report all the validation errors and based on some helpful advice/code from the earlier posts in this forum, I have used the following code to validate and report the errors.
    The code works fine but for large files it never goes beyond a certain number of errors i.e. getNumMessages() (XMLParseException) never returns value greater than 100 and thus limits the output of the validation errors. Any pointers to suggest change in code or an alternative will be extremely helpful.
    Datebase Version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED as package <package name>;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.sql.SQLException;
    import oracle.sql.CLOB;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    public class XMLSchemaVal
    public static String validate(CLOB xmlDoc, CLOB xsdDoc)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    Reader xsdInUnicodeFormat = xsdDoc.getCharacterStream();
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdInUnicodeFormat, null);
    //Build XML Object
    Reader xmlInUnicodeFormat = xmlDoc.getCharacterStream();
    // Genereate the SAX
    SAXParser saxparser_doc = new SAXParser();
    // Set Schema Object for Validation
    saxparser_doc.setXMLSchema(schemadoc);
    saxparser_doc.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxparser_doc.setPreserveWhitespace (true);
    String returnValue;
    try {
    saxparser_doc.parse (xmlInUnicodeFormat);
    returnValue = "The input XML parsed without errors.\n";
    catch (XMLParseException se) {
    returnValue = "Parser Exception: ";
    for (int i=0 ; i < se.getNumMessages(); i++)
    returnValue += "<LN: " + se.getLineNumber(i) + ">: " + se.getMessage(i);
    //returnValue = "Parser Exception: " + se.getNumMessages();
    catch (Exception e) {
    returnValue = "NonParserException: " + e.getMessage();
    return returnValue;
    Function to call the above utility from PL/SQL
    CREATE OR REPLACE FUNCTION F_XMLSCHEMAVALIDATION (P_XML IN clob ,P_XSD IN clob) RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME XMLSchemaVal.validate(oracle.sql.CLOB,oracle.sql.CLOB) return java.lang.String';
    Thanks.

    I have the same question. I have an external DTD. I wish to parse an xml file using XMLParser.xmlparse. If I first call XMLParser.xmlparseDTD and then call xmlparse with the XML_FLAG_VALIDATE will the xml automatically be validated against the previously parsed DTD? There is no DOCTYPE declaration in the xml file.
    The demo code on OTN for Java is great but has no relation to the code you would use in C++ (no set functions in C++).

  • XML Validation using XDK SAX/DOM Parser

    Hello,
    I am trying to validate xml against xsd using SAX/DOM parser, both the files are stored as CLOB column in the database. I have the requirement to report all the validation errors and based on some helpful advice/code from the earlier posts in this forum, I have used the following code to validate and report the errors.
    The code works fine but for large files it never goes beyond a certain number of errors i.e. getNumMessages() (XMLParseException) never returns value greater than 100 and thus limits the output of the validation errors. Any pointers to suggest change in code or an alternative will be extremely helpful.
    Datebase Version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED <> as package <package name>;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.sql.SQLException;
    import oracle.sql.CLOB;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    public class XMLSchemaVal
    public static String validate(CLOB xmlDoc, CLOB xsdDoc)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    Reader xsdInUnicodeFormat = xsdDoc.getCharacterStream();
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdInUnicodeFormat, null);
    //Build XML Object
    Reader xmlInUnicodeFormat = xmlDoc.getCharacterStream();
    // Genereate the SAX
    SAXParser saxparser_doc = new SAXParser();
    // Set Schema Object for Validation
    saxparser_doc.setXMLSchema(schemadoc);
    saxparser_doc.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxparser_doc.setPreserveWhitespace (true);
    String returnValue;
    try {
    saxparser_doc.parse (xmlInUnicodeFormat);
    returnValue = "The input XML parsed without errors.\n";
    catch (XMLParseException se) {
    returnValue = "Parser Exception: ";
    for (int i=0 ; i < se.getNumMessages(); i++)
    returnValue += "<LN: " + se.getLineNumber(i) + ">: " + se.getMessage(i);
    //returnValue = "Parser Exception: " + se.getNumMessages();
    catch (Exception e) {
    returnValue = "NonParserException: " + e.getMessage();
    return returnValue;
    Function to call the above utility from PL/SQL
    CREATE OR REPLACE FUNCTION F_XMLSCHEMAVALIDATION (P_XML IN clob ,P_XSD IN clob) RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME XMLSchemaVal.validate(oracle.sql.CLOB,oracle.sql.CLOB) return java.lang.String';
    Thanks.

    Got the answer !!!
    NetBeans it self support generation of dtd file based on XML file.
    Open XML file and right click on the code block. Select option to generate dtd file.
    This is the drtd file it has generated..
    <?xml version='1.0' encoding='UTF-8'?>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT book (person)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT person (age|last|first)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT first (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT last (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT age (#PCDATA)>

  • How to change parsing schema for using application in test environment?

    Hi,
    I set up a test environment, i.e. an other Oracle schema with identical tables, views etc. to the productive environment. I wanted to duplicate the APEX application so that there will be a test version using the test Oracle schema and productive version using the productive oracle schema.
    Can some one please give me some tip how to do this? As far as I see i could change the parsing schema in the APEX Application install SQL in the following ways:
    1. While exportin the application with APEX
    2. In the result install f...sql file using search-replace
    3. While importing the APEX application via APEX Development GUI.
    I would prefere 1. or 3. but in both cases when I would like to change the schema name, the drop dowl list does not contain the test Oracle schema name. Do I have to grant something to the APEX worksspace schema for the test schema name to show up in the drop dowl list?
    Tamás

    On that screen,
    - click Create
    - select "Existing" Schema, click Next
    - select the Workspace, click Next
    - select the Schema, click Next
    - click Add Schema
    And now you'll end up with two schema's attached for the same Workspace.

  • Validating xml file against a specific schema using jaxp sax parser

    Hi,
    I would like to validate a soap xml given below
    <?xml version="1.0" encoding="UTF-8"?>
    <Envelope>
         <Body>
              <name>pavan</name>
              <number>123</number>
         </Body>
    </Envelope>
    to validate against the schema of soap from url "http://www.w3.org/2003/05/soap-envelope". I dont want to have this namespace in the xml. How can I validate against the specified schema using jaxp sax parser?
    Please help.
    Thanks,
    T.Pavan kumar

    Any one, please help.

  • HOW TO: Use the XML parser in Oracle 8.1.7

    I am trying to figure out how to use the xml parser provided in oracle 8.1.7. all i want to do is parse a xml report that is defined using a schema, and place the data into the proper tables. i am totally unfamiliar with the xml parser and how it works. i have done some reading on the subject, but seem to be getting some conflicting infromation about which utilites i need and how to invoke them. can someone please tell me what utilities i need, how to invoke them, and what i need to do to get a xml document to parse and insert to a table? I would greatly appreciate any help anybody could offer. thanks.

    You can parse the XML Document with XML Parser and place the data into database using XSU(XML SQL Utility).
    Both of these are included in XDK for Java at:
    http://otn.oracle.com/tech/xml/xdk_java
    The following document could also help:
    Oracle9i XML Developer's Guide--XDK [PDF] at http://otn.oracle.com/tech/xml/doc.html

  • HOW TO have LOV display values from a table not contained in parsing schema

    I am using DAD to log in and have been able to get around the problems associated with the login schema being different than the parsing schema. However, I want to have a list of values to be shown to the user based on a table in the DAD schema that they log into rather than the parsing schema.
    Anyone know how this might be done?

    GOT IT:
    RETURN 'select xxxxxxx' does it

  • How to download a file from a table not in the parsing schema

    We have a table in another schema which holds files in a blob column. I can create a form on this table and the file upload works fine. The file browse page item has the source as the blob column and storage type "BLOB column specified in Item Source attribute". The download link generated for the page shows a call to apex_util.get_blob_file and the parameters are correct. However, when you click on the link you get a Page Not Found 404 error. Same error in Apex 4.1.1. The plsql error is:
    ORA-20544: Invalid table owner
    ORA-06512: at "APEX_040000.WWV_FLOW_DML", line 1628
    ORA-06512: at "APEX_040000.HTMLDB_UTIL", line 2244
    ORA-06512: at line 31
    Is there a way to use apex_util.get_blob_file to download a file when the table is in another schema?
    Rod West

    Hi,
    I am not sure that the post explains everything as the "Automatic Row Processing" and "Automatic Row Fetch" process work fine on this page and therefore security should not be an issue.
    Thanks for the view suggestion, but I am not sure that a view is a good option for us because the parsing schema does not have create view privilege and therefore the view would be difficult to install and maintain. We will problably end up with a custom download file process.
    Rod West

  • How to change parsing schema for REST

    Hi all,
    I'm trying to test the new REST Webservice feature, but this leads to an error:
    Using Apex 4.2.1.00.08, Listener 2.0.1.64.14.25 I set up a simple WebService (method: GET, format: JSON) which
    querys a table.
    When I try to test my webservice (using "Test" button) the following error is shown:
    Request Path passes syntax validation
    Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=null, _failed=false, _lastUpdate=-1, _template=null, _type=REGEX]
    Applied database connection info
    Attempting to process with PL/SQL Gateway
    Not processed as PL/SQL Gateway request
    Attempting to process as a RESTful Service
    Determining if request can be dispatched as a Tenanted RESTful Service
    Request path has one path segment, continuing processing
    No Tenant Principal established yet, continuing processing
    APEX_LISTENER pool exists, continuing processing
    Matching tenant exists, continuing processing
    modul/template/ matches: modul/template/ score: 0
    Choosing: oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as current candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=1019223475312614|5204902308237886, uriTemplate=modul/template/], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true]
    Determining if request can be dispatched as a Tenanted RESTful Service
    Request path has one path segment, continuing processing
    Tenant Principal already established, cannot dispatch
    Chose oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as the final candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=1019223475312614|5204902308237886, uriTemplate=modul/template/], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true] for: GET modul/template/
    Choosing: oracle.dbtools.rt.jdbc.entity.JDBCTenantDispatcher as current candidate with score: Score [handle=oracle.dbtools.rt.jdbc.entity.JDBCTenantDispatcher$TenantTarget@1537060, score=1, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true]
    Chose oracle.dbtools.rt.jdbc.entity.JDBCTenantDispatcher as the final candidate with score: Score [handle=oracle.dbtools.rt.jdbc.entity.JDBCTenantDispatcher$TenantTarget@1537060, score=1, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true] for: GET prx/modul/template/
    prx/modul/template/ is a public resource
    modul/template/ is a public resource
    Using generator: oracle.dbtools.rt.json.query.JSONQueryGenerator
    Performing JDBC request as: POFFICE
    Error during evaluation of resource template: ORA-00942: Tabelle oder View nicht vorhanden
    I see what is going wrong: "Performing JDBC request as: POFFICE". JDBC is using a wrong schema ("POFFICE").
    So, my question is, how to change the parsing schema for JDBC/WebService?
    Thanks a lot,
    Michael

    jfle wrote:
    Yes - this is the reason,
    but is there a way to change or delete the first schema provisioned?See {message:id=3757162}
    We have deleted the poffice assignment to the workspace, but the REST-service executes with poffice?Don't know could be a bug.
    May be try exporting you restful webservice definition > Edit the export file in textpad/notepad and verify the parsing schema
    You will see a block something like below, there just amend the p_parsing_schema to desired > and then import it back
    wwv_flow_api.create_restful_module (
      p_id => 7113266627142076447 + wwv_flow_api.g_id_offset
    ,p_name => 'oracle.example.vikram2'
    ,p_parsing_schema => 'APX'
    ,p_items_per_page => 25
    ,p_status => 'PUBLISHED'
      );

Maybe you are looking for