Using XML Schema in SFP.
Hi..
We have requirement to send the form output in xml file.
The xml file has been picked up PI system and post it in SAP.
But the PI conversion routine looking for specific field names which are usually more than 30 Char. length.
So its not possible to go for DDIC interface in SFP. rather we are thinking of going for a xml schema based interface.
Calling an XSLT routine to swap the field names required by the PI system.
one more thing is we also have some default values populated in the form fields which is also should be populated in the new xml fields.
Is XSLT routine is a solution for this issue ?! or any other ideas ?
Thanks
Sam
Hi Otto,
The form data output directly send to the PI system via Email.
But we change the interface field names closer to PI requirement.
Thanks for your response.
I am closing this thread.
Cheers
Sam
Similar Messages
-
Can't i use xml schema and oledb data connection at the same time?
Hello to all and thanks in advance.I use xml schema and oledb data connection at the same time and the problem is that when I try to export the xml, the outcome is not what i expect.Without the oledb connection everything is ok (just the schema) and the xml complies with the schema.
Can't i have both schema and oledb and the exported xml be as i want it?You can use both at the same time, but not gor Internet access if that's what you're asking.
Now there is a thing called Link Aggregation, which combines a number of interfaces for speed/redundancy, but it really only works locally, and then only with ALL special equipment in the route, and most likely OSX Server involved.
Sorry. -
PL/SQL web service - how to use XML schema to define inputs/outputs?
Hello,
let us say I want to publish a PL/SQL web service. The package spec that I want to expose is:
CREATE OR REPLACE PACKAGE myWebService AS
FUNCTION loadResults(
username IN VARCHAR2,
password IN VARCHAR2,
resultData IN XMLType)
RETURN XMLType;
END;When I use JDeveloper's wizard to publish my PL/SQL web service, the resulting WSDL contains this:
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://uk/co/weatherbys/aapws/AAPWS.wsdl/types/"
targetNamespace="http://uk/co/weatherbys/aapws/AAPWS.wsdl/types/"
elementFormDefault="qualified">
<element name="loadresultsElement">
<complexType>
<sequence>
<element name="username" type="string" nillable="true"/>
<element name="password" type="string" nillable="true"/>
<element name="resultdata" nillable="true">
<complexType>
<sequence>
<any/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="loadresultsResponseElement">
<complexType>
<sequence>
<element name="result" nillable="true">
<complexType>
<sequence>
<any/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>It is specifying that anything at all can be passed in and out from the two XMLType arguments, which is fair enough: it has no way of knowing what I am expecting and what I shall return.
My question is, how do I tell JDeveloper that actually I want either or both of those XMLTypes to conform to a particular XML schema?You cannot format the date as a string, unless you do the conversion on the PL-SQL side, before you use it in your WebService mapping. It should be handled as a string.
The only way to convert the XML from SOAP, using this encoding, into literal XML is to apply XSLT to the payload. Not sure why you would like to do this, as the payload should be consumed by another SOAP-awared stack.
Hope this helps,
Eric -
Using xml schema problem (SAP MDM 7.1 Syndicator)
Good day !
I try to syndicate directory which correspond to some xml-schema and I have a problem.
I want to syndicate data from hierarchy table which have one field which have a type like lookup <Flat> (multivalued).
In XML-schema element "DEF_PRODUCT" and "DEF_PRODUCT_CODE" - attribute presents hierarchy table.
"CREDIT_PRODUCT" and childs presents linked flat table.
According idea and business rules I must get the result like this: each "DEF_PRODUCT" have N-"CREDIT_PRODUCT". One - to- many.
But when I set up all map completely and look to xml result file I start to be disappointed.
XML result file approximately must be like this:
<DEF_PRODUCT>
<CREDIT_PRODUCT/>
<CREDIT_PRODUCT/>
<CREDIT_PRODUCT/>
</DEF_PRODUCT>
but in result I have all <CREDIT_PRODUCT> in one node and child attributes.
I attach 3 pics which explain my situation.
xml-schema :[http://xmages.net/storage/10/1/0/6/3/upload/42ca6ca8.jpg]
field mapping: [http://xmages.net/storage/10/1/0/6/a/upload/bbbc09f2.jpg]
example: [http://xmages.net/storage/10/1/0/c/c/upload/817b0e23.jpg]
Anybody can help me?
About software : SAP MDM 7.1 (7.1.04.139)
P.S: My problem can be resolved succesfully if I will use 1 <main> table and 1 <qualified flat> table.
But in my case I must use hierarchy - structure because it most usable for business - users>
Christian Heuer wrote:
> Hi,
>
> now I understood and you really have got a point here. But the question is whether you need key mapping then on the remote key level with a tuple anymore. If yes, you won
>
> Best regards
> Christian
If SAP MDM will present many opportunities to me I will be very glad.
I repeat I must get output xml which have the pair like "RemoteKey"="RemoteSystem" in tuple subnode.
In tuple, after your advices.
Ideally, Syndicator must present to each user ability to choose pair "RemoteKey" = "RemoteSystem" in each subnode like <LookUp> table in root (look at my example pic).
Imagine you have one root table and N-linked <lookup> tables.
Tree like this :
<main tbl>
<subtbl1/>
<subtbl2/>
<subtbl3>
<childtbl1/>
<childtbl2/>
</subtbl3>
</main tbl>
It's dangerous to deprive SAP MDM user to select pair "RemoteKey" = "RemoteSystem" from ROOT to ALL and LAST LEAF in abstract hierarchy. How do you think ?
Now, I haven't abilities to solve my problem using standard resources. Really ? -
Using XML schema in a Java application
Hi,
I need to parse and use an XML schema in an application, mainly for helping a user to build an XPATH.
For that, I want to use the Schema classes bundled with Oracle's parser. Is there any documentation about that ? Or are the source code available ?
Thank's
Phil.See the JavaHelp article on my site.
I had developers saying they had to have JavaHelp for their
Java application. After discussion we established that for where
this was going to be used, webhelp was just as acceptable. Being
easier for us that won the day. -
Generating a XML using XML Schema
Hi,
I have a requirement where I need to generate a XML which should follow XML Schema. If XML schema changes, i should still be able to generate XML file. Any sample code or idea will help me.http://java.sun.com/webservices/jaxb/users-guide/jaxb-using.html
This tutorial is a good place to start. ideally you will use the xjc.bat file present in
jwsdp-2.0 (thats whaty i use) to generate a package full of classes that corresponds to your
schema.
Use ANT-build script to generate this package then you will do some marshalling
followed by validating against a DTD, and unmarshalling - to do get java objects out of XML -
Xform validation by using Xml-schema
Hello,
I want to validate XForm by using XForm Schema. In an xform example attached below , there are two input fields zip and zip2.
I am not getting why zip in xform attached below cannot be validated.But zip2 is working fine. I am using mozilla firefox browser.
XForm and XMLSchema is attached below.
XForm is
<?xml version="1.0" encoding="UTF-8"?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ftype="http://www.example.com/my-file-types">
<head>
<title>Validate Postal Codes</title>
<style type="text/css">
@namespace xf url("http://www.w3.org/2002/xforms");
xf|input {
display: table-row;
line-height: 2em;
xf|label {
display: table-cell;
text-align: right;
font-family: Arial, Helvetica, sans-serif;;
font-weight: bold;
padding-right: 5px;
width: 150px;
*:required {
background-color: yellow;
*:invalid {
background-color: pink;
</style>
<xf:model schema="schema.xsd">
<xf:instance>
<data xmlns="http://www.example.com/my-file-types">
<zip/>
<zip2/>
</data>
</xf:instance>
<xf:bind id="zip" required="true()" type="ftype:zipType" nodeset="ftype:zip" />
<xf:bind id="zip2" required="true()" type="ftype:zip2Type" nodeset="ftype:zip2" />
</xf:model>
</head>
<body>
<xf:input bind="zip" incremental="true">
<xf:label>Zip Code: </xf:label>
<xf:hint>Validation is not correctly specified for this field</xf:hint>
<xf:alert>The 'Zip Code' failed to validate!</xf:alert>
</xf:input>
<xf:input bind="zip2" incremental="true">
<xf:label>Zip Code 2: </xf:label>
<xf:hint>Validation is correctly specified for this field</xf:hint>
<xf:alert>
<xf:output value="concat('The "', name(), '" failed to validate!')" />
</xf:alert>
</xf:input>
</body>
</html>--------------------------------------------------------------------------------
And XML Schema is
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ftype="http://www.example.com/my-file-types" targetNamespace="http://www.example.com/my-file-types" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:element name="zipType">
<xs:simpleType id="zipType">
<xs:restriction base="xs:string">
<xs:enumeration value="b"/>
<xs:enumeration value="computer"/>
<!-- bad pattern: matches any sequence of 5 digits, even if there are more digits or non-numeric. -->
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="zip2Type">
<xs:restriction base="xs:string">
<xs:pattern value="^\d{2}$"/>
<!-- good pattern: matches only 2 digits, nothing extra -->
</xs:restriction>
</xs:simpleType>
</xs:schema>Looking for some reply.
Best Regards
TabbasumHi Otto,
The form data output directly send to the PI system via Email.
But we change the interface field names closer to PI requirement.
Thanks for your response.
I am closing this thread.
Cheers
Sam -
XML generation with SAP data using XML schema - Reg
Hello experts,
My requirement is , SAP( ztable data ) data has to be transferred to third party software folder.Third party using XML so they requires output from SAP in XML format.
For that third party software guys told me that they will give their own XML schema to me.I have to generate XML file with SAP data using their XML schema.
Generating XML file with their Schema should be underlined.
I studied that call transformation statement helps for this.
Even then i don't have clear idea about this topic.
Please brief me about how to use their XML schema to generate XML with my own sap data.
Thanks in advance experts.
Kumarplease try this same program and see it ....
*& Report z_xit_xml_check
REPORT z_xit_xml_check.
TYPE-POOLS: ixml.
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line,
l_xml_line TYPE t_xml_line,
l_xml_table_size TYPE i.
DATA: l_filename TYPE string.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:temporders_dtd.xml'.
* Validation of XML file: Only DTD included in xml document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
START-OF-SELECTION.
* Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
* wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
* Creating a document
l_document = l_ixml->create_document( ).
* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
* Validate a document
IF pa_val EQ 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
* Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
* Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
FORM get_xml_table CHANGING l_xml_table_size TYPE i
l_xml_table TYPE STANDARD TABLE.
* Local variable declaration
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
* upload a file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. "get_xml_table
*& Form process_dom
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE: /.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL. EXIT. ENDIF.
* create a node iterator
iterator = node->create_iterator( ).
* get current node
node = iterator->get_next( ).
* loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
* element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
* attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
* text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
* advance to next node
node = iterator->get_next( ).
ENDWHILE.
ENDFORM. "process_dom
reward points if it is use fulll ....
Girish -
Defining entities using XML schema
Hi,
We have defined an XML schema for our data by converting a DTD, but I cannot figure out how to allow for entity definitions that
are non-standard. e.g. we have a entity called "°", defined in the DTD as "°". How would I allow for such entries
in the data when parsing it against a schema?
Thanks
PeteHi,
Interesting how the character gets displayed as an actual degree.
The unicode is u00B0.
Any ideas anyone?
Thanks
Pete -
Webservices and xml schema valdiation
Hi everyone,
I have a method call thru web services, where the xml document comes as a string. I need to validate the xml document using xml schema. I have searched the xerces and dom4j apis, but couldn't find anything which allows me to validate an xml document, coming as a document, or as a string (not the location to the file system).
can anyone help with any resource site, or any code , thats going to be of great help.
thanxDOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"test.xsd");
hope this helps. -
Java Stored Procedure SAXParser XML Schema Validation
Using Oracle XML Developers Kit 10.2.0.2.0 - Production.
Attempting to validate using XML Schema in a Java stored procedure with the code:
if ( schemaDoc == null )
// Obtain default connection
Connection conn = new OracleDriver().defaultConnection();
OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement("SELECT XmlDocObj FROM XmlDoc WHERE XmlDocNbr = 2");
OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
if ( rset.next() )
// get the XMLType
XMLType schemaXml = (XMLType)rset.getObject(1);
XSDBuilder builder = new XSDBuilder();
XMLSchema schemaDoc = (XMLSchema)builder.build(new InputSource(schemaXml.getInputStream()));
if ( inst == null )
inst = new ValidateCoreRequest();
ErrorHandlerImpl handler = inst.getNewErrorHandler();
SAXParser saxParser = new SAXParser();
saxParser.setXMLSchema(schemaDoc);
saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
saxParser.setErrorHandler(handler);
saxParser.parse(new InputSource(new StringReader(docStr)));
if( handler.validationError )
errorMsg[0] = handler.saxParseException.getMessage().substring(0, Math.min(199, handler.saxParseException.getMessage().length()));
Never reports validation errors in the XML. Although the XDK Programmers Guide states "...you can use
the oracle.xml.parser.schema.XSDBuilder class to build an XML schema and
then configure the parser to use it by invoking the XMLParser.setXMLSchema()
method. In this case, the XML parser automatically sets the validation mode to
SCHEMA_STRICT_VALIDATION and ignores the schemaLocation and
noNamespaceSchemaLocation attributes." No validation seems to occur. I have tried to set an xsi:noNamespaceSchemaLocation attribute on the root XML node, but this results in URL errors if the URL is not valid or schema build errors if the URL is valid, but does not point to a real location.
It appears that without a schema location attribute, no schema validation occurs. Using setXMLSchema() with a database source does not seem to cause the schema location attributes to be ignored. At least for Java stored procedures.
Does XML Schema validation work in the database for externally referenced schemas?
Thank You,
Art<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jan Vissers ([email protected]):
I have two schemas A and B. A contains a java stored procedure which calls a java stored procedure stored in B. Upon resolving the "A" Java Stored Procedures I get the following error:
ORA-29545: badly formed class: at offset 3093 of Adapter.TFADPBeschikbaarheid.sendAanvraag expecting a class-oracle.xml.parser.v2.XMLDocument but encountered a class-oracle.xml.parser.v2.XMLDocument.
... Question:
it is expecting something which it has in fact encountered... SO!!!! What is the error.
Thx,
Jan<HR></BLOCKQUOTE>
Try this:
Edit your XSU installation script located on lib directory of Oracle XSU's distribution:
Find the line:
loadjava -r -v -u $USER_PASSWORD xmlparserv2.jar
Replace by:
loadjava -r -v -g public -u $USER_PASSWORD xmlparserv2.jar
And installs your Oracle XSU again.
Best regards, Marcelo. -
Hi,
Can some one please give me a pointer or elaborated detail regarding how using xml schema helps instead of using DTDs and the most popular and efficient tool out there that converts DTDs into XSDs? I know there is some inforamtion about this in W3C documents, anything more consice than the W3C documents will help.
Thanks,usermolak wrote:
Can some one please give me a pointer or elaborated detail regarding how using xml schema helps instead of using DTDs Check this out:
Oracle® XML DB Developer's Guide - How DTDs and XML Schema Differ
and the most popular and efficient tool out there that converts DTDs into XSDs?
I use Altova XML Spy. This editor is used in many examples in the Oracle Documentation.
Cheers,
Mihajlo -
Validation with jaxp 1.3 and xml-schema
I'm totally green when it comes to xml&jaxp. Using jse 1.5 (jaxp 1.3), I'm trying
to have my app parse and validate an xml doc with xml schema. I want the validation to
happen using the schema specified in the xml doc. Also, I'd prefer if my application didn't have to set
the schema to use. As far as I can make out though, it appears that I need to parse the schemaLocation when
I want to validate using xml schema. Anyone know a way to avoid that step?
If not, then any idea why I'm getting the following err?
Error...
junit.framework.AssertionFailedError: null/null:4,9: Document is invalid: no grammar found.null/null:4,9: Document root element "catalog", must match DOCTYPE root "null".
at junit.framework.Assert.fail(Assert.java:47)
at com.rwd.toolbox.junit.AbstractRwdTestCase.printAndFail(AbstractRwdTestCase.java:229)
at com.rwd.util.xml.XmlUtilsTests.testXmlValidationUsingSchemaDefinedInXmlDoc(XmlUtilsTests.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Code... obviously taken from junit test case...
DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
documentFactory.setNamespaceAware(true);
documentFactory.setValidating(true);
DocumentBuilder builder = documentFactory.newDocumentBuilder();
com.rwd.util.xml.Validator v = new com.rwd.util.xml.Validator(_validationStyle);
builder.setErrorHandler(v);
Document document = builder.parse(_document);
where com.rwd.util.xml.Validator extends DefaultHandler. Note that if I add following
code, then validation works as i expect it... but that's not really an option I care for (at least in this case).
I would anticipate being able to have the parser see the XSD reference in the XML and
apply it. Anyway, here's code to programmatically specify an XSD to use for validation....
documentFactory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
documentFactory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaSource",
"file:///C:/workspace31m4/LMSTester/testData/util/xml/o.xsd");
Finally, the XML file... (example from onJava site)... Note that I've tried changing the URI to file:///c:/..., same result:
<?xml version="1.0" encoding="UTF-8"?>
<!--A OnJava Journal Catalog-->
<catalog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file://C:/workspace31m4/LMSTester/testData/util/xml/o.xsd"
title="OnJava.com" publisher="O'Reilly">
<journal date="April 2004">
<article>
<title>Declarative Programming in Java</title>
<author>Narayanan Jayaratchagan</author>
</article>
</journal>
<journal date="January 2004">
<article>
<title>Data Binding with XMLBeans</title>
<author>Daniel Steinberg</author>
</article>
</journal>
</catalog>
and its XSD file (also from onJava)...
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="catalog">
<xs:complexType>
<xs:sequence>
<xs:element ref="journal" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="title" type="xs:string"/>
<xs:attribute name="publisher" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="journal">
<xs:complexType>
<xs:sequence>
<xs:element ref="article" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="date" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="article">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element ref="author" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="author" type="xs:string"/>
</xs:schema>
Thanks,
-PaulThere are other applications using Xerces1.0 so the requirement is that I cannot replace the Xerces jar. Any suggestions.
-
Issues faced with XML (Objt-Rel) - Plan to move to Binary XML (schema-less)
Hi All,
Our Production DB has Oracle XMLDB implementation using 9 XMLDB Object-Relational
Tables. These have been implemented almost since a year, and we faced several issues,
have listed some of the most important ones:
Obviously it is Object-Relational implementation, so we have 4-5 XSDs to start with that
support the Object-Relational schema
1) copyEvolve Issues : Due to changing Business Requirements constantly, we had to constantly
and continuously modify/upgrade XSDs and then use "copyEvolve" to apply new XSDs
Encountered several issues with CopyEvolve
2) "Home-grown" solution to evolve XSD/Schema:
We came up with our own Solution to migrate/evolve XSD schema.
a) Backup all data from 9 XML DB Tables to 9 CLOB Tables (data is thus "dereferenced" and "delinked"
from underlying XSDs
b) Since data is backed up to CLOB Tables, go ahead and drop the entire schema and register
new XSDs and recreate Tables. (GRANTS and PUBLIC SYNONYMS reappled, needless to say)
c) Reload data from backed up CLOB Tables to newly created XMLDB (Obj-Relational) Tables
Above approach (without "copyEvolve") has worked fine so far and helped in each Release/ every migration
With our data sets becoming increasingly huge, downtime is not sufficient to follow this successful, home-grown
approach and as a result we would like to get away from Object-Relational XMLDB Tables altogether.
3) Our Application currently uses XPath heavily on all 9 XMLDB Tables and we understand XPath is already
deprecated by Oracle (as of 11.2.0.2)
We are seriously considering doing the following:
1) Migrate all 9 XMLDB Tables and modify underlying Storage from "Object-Relational" to Binary XML (Schema-less)
2) Modify Appln code with all XPath replaced by corresponding XQuery constructs
3) Replace existing "B-TREE" based Indexes in Object-Relational XMLDB Tables with either a) Indexes on Virtual DB Columns to enforce Primary Key and Unique Constraints and b) XMLIndex on all other Non-Unique Columns instead of
the corresponding "B-TREE" based Indexes
What we hope to achieve with the above:
1) Eliminate XSD Usage completely (and copyEvolve nightmares thereby)
2) Eliminate Usage of XPath totally
3) Better Performance overall :-)
Would like to get some advice and feedback on our Proposed Plan and mainly are we taking the
right direction especially in respect of Performance, Point 3) listed above
Any feedback or tips would be truly appreciated
Regards and Thanks
AuroWRT to XPATH Vs XQuery.
1. XPATH is a subset of XQuery.. Any XPATH expression is, by definition, an example of simple XQuery expression, so XPATH is not depricated.
2. What we are depricateing are the older, oracle specific XML operators (EXTRACT(), EXTRACTVALUE(), EXISTSNODE()), that ONLY support XPATH. We are depricating these in favour of the new SQL/XML operators (XMLTABLE, XMLQUERY, XMLEXISTS) defined by the SQL standards committee. These operators provide support for the full XQquery standard, and implicitly all of the XPATH expressions that were supported by the older operators. This menas we strongly recommned that new code, developed to work with 11g make use of nrw newer operators. Personally I cannot see a point where we would ever consider de-supportting the older operators, we are well aware of how much code makes use of them.
What this means is that any code that is written using the older operators will continue to work, unmodified. However should a bug surface in the use of the older operators, we would strongly recommend that the code in question be migrated to the new operators as part of the remidiation process.
Also, once the initial pain of learning the new syntax is overcome, I truely believe that the new operators result in much more efficient and mantainable code, so taking the time to do code renevation when possible will probably pay off in the long term...
WRT to moving away from Schema-Based OR storage, I would look at the kind of changes you have made to the XML Schema. If they are the kind of changes that would be supported by in-place evolution in 11g then you might want to re-consider this. If, on the other hand you are regularly making changes to the XML schema that are not backwardsly compatable with your older XML Schema then Schema-Based binary XML storeage (which is more flexible than Schema-Based Object-Relational storage) or even non-schema based Binary XML may be a better choice for your applicaiton..
I would experment by registering the oldest version of your XML Schema in 11gR2, and then testing each of the evolutions you have gone through to see if 11GR2 inplace evolution would have managed them. Also, ask yourself do you expect your XML Schema to keep changing so drastically moving forward, or were some of these changes the results of the growing pains associated with learning how to use XML schema effectively. BTW the approach you outline is effectively what CopyEvolve is doing under the covers...
Bear in mind that for the use-cases Object-Relational storage addesses, when all of the XPATH expressions are correctly re-written into SQL operations on the underlying tables, and where the majority of queries end up accessing or updating leaf-level nodes in the XML, it is unlikely that a Binary XML / Unstructured XML Index combination will deliver similar performance. If you are only accesss a small subset of the leaf-level nodes, creating structured XML Indexes that project out the nodes in question may be able to deliver similar performance to an Object-Relational storage model, but you will need to get the index definitions correct.
-Mark
Edited by: mdrake on Mar 7, 2011 7:40 PM -
Hi,
I'm getting an error trying to validate an xml document using xml schema(xsd). The java code/schema/xml/error are listed below.
Not sure what the error
" Invalid content was found starting with element 'ticker'. One of '{ticker}' is expected." means.
Using jre 1.6
Any input appreciated.
Thanks !
// Java Code
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(schemaURL);
Validator validator = schema.newValidator();
validator.validate(new StreamSource(is));
// Schema
<xs:element name="stocktrade">
<xs:complexType>
<xs:sequence>
<xs:element name="ticker" type="xs:string"/>
<xs:element name="price" type="xs:string"/>
<xs:element name="quantity" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
// XML doc
<stocktrade
xmlns ... and other attributes
>
<ticker>aaa</ticker>
<price>23.5</price>
<quantity>11</quantity>
</stocktrade>
// Error
Exception in thread "main" org.xml.sax.SAXParseException: cvc-complex-type.2.4.
: Invalid content was found starting with element 'ticker'. One of '{ticker}' i
expected.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSA
ParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Un
nown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErr
rReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.report
chemaError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handle
tartElement(Unknown Source)When I tried this with Xerces SAX, I got---
org.xml.sax.SAXNotRecognizedException: http://java.sun.com/xml/jaxp/properties/schemaLanguage
Maybe Xerces has not implemented the schemaLanguage property.
I have been successfully using Xerces-dependent properties to do validation:
XMLReader parser = saxParser.getXMLReader();
parser.setFeature( "http://xml.org/sax/features/validation", true);
parser.setFeature( "http://xml.org/sax/features/namespaces", true);
parser.setFeature( "http://apache.org/xml/features/validation/schema", true);
parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);
if (noNamespaceSchemaLocation!=null) {
parser.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
noNamespaceSchemaLocation);
if (schemaLocation!=null) {
parser.setProperty(
"http://apache.org/xml/properties/schema/external-schemaLocation",
schemaLocation);
Also, as DrClap pointed out, for the schema location I use URIs.
Please let me know if you got the jaxp schemaLocation property to work and how you did it.
Maybe you are looking for
-
I love my galaxy nexus but how can I love a phone that drops my calls regularly? I just got off the phone with Verizon technical support after a week-long struggle and they can't do anything for me. So when I first got my phone I had dropped calls an
-
Booklet printing of A4 pages on A3 paper
I would like to print A4 pages on A3 paper in booklet form. I select Booklet Printing + Front side only + A3 media size. The pages print off centre. They are scaled correctly but not positioned correctly. What esle to I need to specify? I had a simil
-
APD Failure with Exception condition "OBJECT_NOT_FOUND" raised.
Dear All, I am executing an APD in my system to clear the contents of 2 of its Fields in a Master data by loading data to itself and initializing the 2 fields that needs to be cleared off. I have executed the APD few times and am getting the same
-
(keyboard layout) changed it but still using the last layout [solved]
I switched my layout from qwerty us to qwerty cf (Canada), it don't work and still use us layout, what could be the trouble ??? Note : followed ArchWiki rc.conf file settings ... Solution : sudo leafpad ~/.config/openbox/autostart ... Add this : setx
-
Are there health risks associated with WiFi?
Hi folks, i've become tired of my ethernet cable unplugging from my mac. So i'm thinking of going wireless. Now here is my question...is WiFi safe? I'm going to bestbuy tonight to check out their wireless routers, (Lynksis WRT54GS-CA), but i'm wonder