Transform XML without validating
Hi, I use Xalan to transform an XML file.
I use Tranformer.class, I just want to tranform the XML without validating the file.
In the parser class, you can use setValidate to avoid or not the validating action.
Do you know how to do the same with Transformer.class
Thanks C�dric
This one piqued my interest, and as no one had responded
yet I thought I'd poke around and see what's up.
I looked at the Transfermer class, and the javadoc pointed
me to the OutputKeys class, the only thing that looked
remotely interesting was the "STANDALONE" feature. I wonder
if you can set it to "true" and avoid the validation (as I
think Standalone implies, no DTD to validate against?)
Eric
Similar Messages
-
Xml transformation without validation
Hi,
How can I carry out an xsl transformation in java without validating the xml document??
regards
anandWell I've a DomSource and I want to transform it using a templates defined in an XSL file.
This is how I'm doing it
Source source = new DOMSource(document);
TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult("temp.xml"));
The stack trace I'm getting is:
ERROR: 'The entity "bull" was referenced, but not declared.'
ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.'
Exception in thread "main" javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:654)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
at temp.Temp.main(Temp.java:115)
Caused by: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:496)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
... 2 more
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
... 3 more
javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:496)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
at temp.Temp.main(Temp.java:115)
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
... 3 more
com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
at temp.Temp.main(Temp.java:115)
org.xml.sax.SAXParseException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1332)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:387)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
at temp.Temp.main(Temp.java:115)
com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
at temp.Temp.main(Temp.java:115)
org.xml.sax.SAXParseException: The entity "bull" was referenced, but not declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1332)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:387)
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
at temp.Temp.main(Temp.java:115)
I don't want to resolve any entity references.
Message was edited by:
anand_nalya -
Copy Signed XML without altering it
Hi everyone,
I have a windows 2003 svr with JRE 1.6.0_18, and xmlsec v1.2.97 jar imported.
I'm building a new module of an existing application, which creates xml for invoices, signs them, and sends them to another company. This signed XMLs are stored on the filesystem.
I need to copy one of such xml files, lets call it A.xml (with valid signature, I checked using DOM's security validation tools) into another xml, lets say B.xml, without altering the contents of A.xml ( therefore voiding the signature ).
Then I have to sign B.xml
I have tried the following so far:
1. using Filereader to copy byte by byte to B.xml.
2. using inputstreamreaders (with apropriate encoding parameter) and copy line by line.
3. using DOM to add new node, and Transformer API to generate B.xml (proper enconding parameters are being set)
when I run a signature validation on B.xml, the signature has become invalid.
One intresting thing though, is that if I use method 1 to copy A.xml to another xml having only A's tree, this new XML has a valid signature.
Has anyone gone through something similar?
I'm I missing something?
or is it that whenever I insert an XML into another, it's signature will become void?
Thank you in advance for your help and time!
Regards,
ReynodWell, #1 should work. Although I didn't understand what you said about "A's tree". Either you copy the file byte for byte (in which case you don't break the signature) or you produce something different (in which case you break the signature).
Anything which changes the contents of the XML should generate a document whose signature is invalid. That's the main point of signing a document. -
Schema of a new Object Type: message pass the BIU without validation
Hi,
i've defined a new Object Type for send messages to Web Service. I've created the schema files and i've uploaded there in repository with the "Import" function of GUI. After, i've defined the XML file for the "Execute" function of the B1i GUI.
After the load of files, in the repository the files are in correct position.
In my BIU the definition of sender and receiver system type is correct, and also the definition of SenderMainObjectTypeID and ReceiverObjectTypeID. The message from B1 pass through the IPO chain without problems and the message is received by teh Web Service.
If modify the file XSL into the BIU, a message with less elements than a schema pass without problem.
If delete the schema from repository, the message pass without validation.
I would know because the schema is bypassed...
ThansOk,
solved with introduction of validation point in a customized IPO using a branch / unbranch atoms.
Bye. -
Java Stored Procedure SAXParser XML Schema Validation
Using Oracle XML Developers Kit 10.2.0.2.0 - Production.
Attempting to validate using XML Schema in a Java stored procedure with the code:
if ( schemaDoc == null )
// Obtain default connection
Connection conn = new OracleDriver().defaultConnection();
OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement("SELECT XmlDocObj FROM XmlDoc WHERE XmlDocNbr = 2");
OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
if ( rset.next() )
// get the XMLType
XMLType schemaXml = (XMLType)rset.getObject(1);
XSDBuilder builder = new XSDBuilder();
XMLSchema schemaDoc = (XMLSchema)builder.build(new InputSource(schemaXml.getInputStream()));
if ( inst == null )
inst = new ValidateCoreRequest();
ErrorHandlerImpl handler = inst.getNewErrorHandler();
SAXParser saxParser = new SAXParser();
saxParser.setXMLSchema(schemaDoc);
saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
saxParser.setErrorHandler(handler);
saxParser.parse(new InputSource(new StringReader(docStr)));
if( handler.validationError )
errorMsg[0] = handler.saxParseException.getMessage().substring(0, Math.min(199, handler.saxParseException.getMessage().length()));
Never reports validation errors in the XML. Although the XDK Programmers Guide states "...you can use
the oracle.xml.parser.schema.XSDBuilder class to build an XML schema and
then configure the parser to use it by invoking the XMLParser.setXMLSchema()
method. In this case, the XML parser automatically sets the validation mode to
SCHEMA_STRICT_VALIDATION and ignores the schemaLocation and
noNamespaceSchemaLocation attributes." No validation seems to occur. I have tried to set an xsi:noNamespaceSchemaLocation attribute on the root XML node, but this results in URL errors if the URL is not valid or schema build errors if the URL is valid, but does not point to a real location.
It appears that without a schema location attribute, no schema validation occurs. Using setXMLSchema() with a database source does not seem to cause the schema location attributes to be ignored. At least for Java stored procedures.
Does XML Schema validation work in the database for externally referenced schemas?
Thank You,
Art<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jan Vissers ([email protected]):
I have two schemas A and B. A contains a java stored procedure which calls a java stored procedure stored in B. Upon resolving the "A" Java Stored Procedures I get the following error:
ORA-29545: badly formed class: at offset 3093 of Adapter.TFADPBeschikbaarheid.sendAanvraag expecting a class-oracle.xml.parser.v2.XMLDocument but encountered a class-oracle.xml.parser.v2.XMLDocument.
... Question:
it is expecting something which it has in fact encountered... SO!!!! What is the error.
Thx,
Jan<HR></BLOCKQUOTE>
Try this:
Edit your XSU installation script located on lib directory of Oracle XSU's distribution:
Find the line:
loadjava -r -v -u $USER_PASSWORD xmlparserv2.jar
Replace by:
loadjava -r -v -g public -u $USER_PASSWORD xmlparserv2.jar
And installs your Oracle XSU again.
Best regards, Marcelo. -
JAXP API provides no way to enable XML Schema validation mode
I am evaluating XDK 9.2.0.5.0 for Java and have encountered another
problem with XML Schema support when using the JAXP API.
Using the classes in oracle.xml.jaxp.*, it appears to be impossible to
enable XML Schema validation mode. I can set the schema object, but
the parser does not use it for validation.
If I use DOMParser directly, I can call the setValidationMode(int)
method to turn on schema validation mode. There is no equivalient
means to enable XML Schema validation when using the JAXP API.
Test case for JAXP API:
=== begin OracleJAXPSchemaTest.java ======
package dfranklin;
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import oracle.xml.parser.schema.XMLSchema;
import oracle.xml.parser.schema.XSDBuilder;
import org.w3c.dom.*;
import org.xml.sax.*;
public class OracleJAXPSchemaTest
private final static String xsd = ""
+"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"urn:dfranklin:test\">"
+" <xsd:element name=\"amount\" type=\"xsd:integer\"/>"
+"</xsd:schema>";
private final static String xml =
"<amount xmlns=\"urn:dfranklin:test\">1</amount>";
public static void main(String[] args)
throws Exception
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"oracle.xml.jaxp.JXDocumentBuilderFactory");
new OracleJAXPSchemaTest().run();
public void run()
throws Exception
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
dbf.setNamespaceAware(true);
XMLSchema xmlSchema = buildXMLSchema(new StringReader(xsd));
dbf.setAttribute("oracle.xml.parser.XMLParser.SchemaObject",
xmlSchema);
DocumentBuilder docbldr = dbf.newDocumentBuilder();
Document doc = docbldr.parse(new InputSource(new StringReader(xml)));
print(doc);
private XMLSchema buildXMLSchema(Reader xsdin)
throws Exception
XSDBuilder xsdBuilder = new XSDBuilder();
XMLSchema xmlSchema = (XMLSchema)xsdBuilder.build(xsdin, null);
return xmlSchema;
private void print(Document doc)
throws
javax.xml.transform.TransformerConfigurationException,
javax.xml.transform.TransformerException
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(new DOMSource(doc), new StreamResult(System.out));
System.out.println();
=== end OracleJAXPSchemaTest.java ======
Running that program:
java dfranklin.OracleJAXPSchemaTest
produces this output
Exception in thread "main" oracle.xml.parser.v2.XMLParseException: Element 'amount' used but not declared.
at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:148)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:269)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:96)
at dfranklin.OracleJAXPSchemaTest.run(OracleJAXPSchemaTest.java:40)
at dfranklin.OracleJAXPSchemaTest.main(OracleJAXPSchemaTest.java:27)
This shows that the parser is not using the XML Schema to validate the
document. I think it's expecting to find a DTD.
Here is the equivalent program using DOMParser directly, and setting
validation mode to SCHEMA_VALIDATION.
=== begin OracleParserTest.java ====
package dfranklin;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import oracle.xml.parser.schema.XMLSchema;
import oracle.xml.parser.schema.XSDBuilder;
import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLParser;
import org.w3c.dom.*;
import org.xml.sax.*;
public class OracleParserTest
private final static String xsd = ""
+"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"urn:dfranklin:test\">"
+" <xsd:element name=\"amount\" type=\"xsd:integer\"/>"
+"</xsd:schema>";
private final static String xml =
"<amount xmlns=\"urn:dfranklin:test\">1</amount>";
public static void main(String[] args)
throws Exception
new OracleParserTest().run();
public void run()
throws Exception
DOMParser dp = new DOMParser();
XMLSchema xmlSchema = buildXMLSchema(new StringReader(xsd));
dp.setXMLSchema(xmlSchema);
dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
dp.parse(new InputSource(new StringReader(xml)));
Document doc = dp.getDocument();
print(doc);
private XMLSchema buildXMLSchema(Reader xsdin)
throws Exception
XSDBuilder xsdBuilder = new XSDBuilder();
XMLSchema xmlSchema = (XMLSchema)xsdBuilder.build(xsdin, null);
return xmlSchema;
private void print(Document doc)
throws
javax.xml.transform.TransformerConfigurationException,
javax.xml.transform.TransformerException
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(new DOMSource(doc), new StreamResult(System.out));
System.out.println();
=== end OracleParserTest.java ====
Running that program
java dfranklin.OracleParserTest
produces this output
<?xml version = '1.0'?>
<amount xmlns="urn:dfranklin:test">1</amount>
In this case, the parser has validated the document.
I also tried this with version 10.1.0.0.0 beta, and got the same
error.
Darin FranklinThanks for posting that. I tried that code and still got my problem. The big difference is that I'm reading a group of XML files each of which uses a large number of schema files. There are over 50 schema files organized so they can be included as needed. Each of the XML files has a noNamespaceSchemaLocation attribute specifying one of the ten top schma files, that includes many others.
However, I did solve the problem. I added one line --
saxb.setFeature( "http://apache.org/xml/features/validation/schema",
true);
// next line is new
saxb.setProperty( JAXPConstants.JAXP_SCHEMA_LANGUAGE,
JAXPConstants.W3C_XML_SCHEMA );after the setFeature to turn on schema validation.
(It needs an import org.apache.xerces.jaxp.JAXPConstants; statement.)
Note:With the feature set to true and the setProperty commented out, the EntityResolver is called at construction tiem, and for each schema file, but each element is flagged as needing to be declared.
With the feature commented out, and the setProperty in place, the EntityResolver is not called, and there is no validation performed. (I added invalid content to one of the files and there were no errors listed.)
With both the setFeature and the setProperty in place, however, I get the calls from the EntityResolver indicating that it is processing the schema files, and for the good files, I get no errror, but for the bad file, I get an error indicating a bad validation.
Now I can make the EntityResolver quiet and get what I wanted. Maybe there are other ways to do this, but I've got one that works. :-)
Thanks to all who have helped.
Dave Patterson -
Hi All
How to tackle this xml schema validation problem
i am using the sample code provided by ORacle technet for xml
schema validation in the Oracle database(817).
The sample code works perfectly fine.
Sample as provided by http://otn.oracle.com/tech/xml/xdk_sample/archive/xdksample_093001.zip.
It works fine for normal xml files validated against
xml schema (xsd)
but in this case my validation is failing . Can you let me know why
I have this main schema
Comany.xsd
===========
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.company.org"
xmlns="http://www.company.org"
elementFormDefault="qualified">
<xsd:include schemaLocation="Person.xsd"/>
<xsd:include schemaLocation="Product.xsd"/>
<xsd:element name="Company">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Person" type="PersonType" maxOccurs="unbounded"/>
<xsd:element name="Product" type="ProductType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
================
which includes the following 2 schemas
Product.xsd
============
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:complexType name="ProductType">
<xsd:sequence>
<xsd:element name="Type" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
==============
Person.xsd
===========
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:complexType name="PersonType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="SSN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
=================
now when i try to validate a xml file against Company.xsd
it throws an error saying unable to find Person.xsd.
no protocol error
Now where do i place these 2 schemas(.xsd files) Person & product
so that the java schemavalidation program running inside Oracle
database can locate these files
Rgrds
SushantHi Jinyu
This is the java code loaded in the database using loadjava called by a wrapper oracle stored procedure
import oracle.xml.parser.schema.*;
import oracle.xml.parser.v2.*;
import java.net.*;
import java.io.*;
import org.w3c.dom.*;
import java.util.*;
import oracle.sql.CHAR;
import java.sql.SQLException;
public class SchemaUtil
public static String validation(CHAR xml, CHAR xsd)
throws Exception
//Build Schema Object
XSDBuilder builder = new XSDBuilder();
byte [] docbytes = xsd.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(docbytes);
XMLSchema schemadoc = (XMLSchema)builder.build(in,null);
//Parse the input XML document with Schema Validation
docbytes = xml.getBytes();
in = new ByteArrayInputStream(docbytes);
DOMParser dp = new DOMParser();
// Set Schema Object for Validation
dp.setXMLSchema(schemadoc);
dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
dp.setPreserveWhitespace (true);
StringWriter sw = new StringWriter();
dp.setErrorStream (new PrintWriter(sw));
try
dp.parse (in);
sw.write("The input XML parsed without errors.\n");
catch (XMLParseException pe)
sw.write("Parser Exception: " + pe.getMessage());
catch (Exception e)
sw.write("NonParserException: " + e.getMessage());
return sw.toString();
This is the code i used initially for validating a xml file against single xml schema (.xsd) file
In the above code could u tell how to specify the second schema validation code for the incoming xml.
say i create another Schemadoc for the 2nd xml schema.
something like this with another parameter(CHAR xsd1) passing to the method
byte [] docbytes1 = xsd1.getBytes();
ByteArrayInputStream in1 = new ByteArrayInputStream(docbytes1);
XMLSchema schemadoc1 = (XMLSchema)builder.build(in1,null);
DOMParser dp = new DOMParser();
How to set for the 2nd xml schema validation in the above code or can i combine 2 xml schemas.
How to go about it
Rgrds
Sushant -
Adapter Engine XML Schema Validation Error Surpression
We recently developed a number of web services that are called by 3rd parties outside our network. The web service request once made is picked up by a Web Dispatcher which then forwards the request to the de-central adapter. Both of these components reside within within a DMZ.
We have, as an additional security measure made use of the new Adapter Engine XML Schema validation available with PI 7.1, to ensure that the payload of incomming messages is checked to ensure that it is a known structure.
Now here is my problem, we recently had these services penetration tested by a 3rd party to ensure that they were secure and whilst the report was very good showing no major weaknesses they did pickup on a couple of items including that the fact that if the XSD to be used during payload message validation cannot be found an 'ADAPTER.JAVA_EXCEPTION' is returned to the web service consumer that highlights the path details of where the XSD should be (but could not be found).
This was viewed as useful to an attacker for a number of reasons:
1. Feedback in SQL injection attempts via verbatim DB error messages greatly improves attacker efficiency
2. Path information is useful to the attacker for OS fingerprinting, directory traversal attempts
3. Other miscellaneous stack trace information is useful to an attacker to understand how the application works
Is there anyway this can be surpressed so that the adapter does not show this information in the returned error message - see example message below ?
com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: Schema MaintenanceOrderByIDQuery_sync.xsd not found in E:\usr\sap\DPI\DVEBMGS40\j2ee\cluster\server0\validation\schema\f7cd3b50a87411e08830ed9d0af006a5\urnstw.contractor.wfm.workorderretrieval\MaintenanceOrderByIDQueryRequest_Out\httpsap.comxiSAPGlobal20~Global\MaintenanceOrderByIDQuery_sync.xsd (validation\schema)
at com.sap.aii.adapter.soap.ejb.XISOAPAdapterBean.process(XISOAPAdapterBean.java:1041)
at sun.reflect.GeneratedMethodAccessor497.invoke(Unknown Source)
com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: Schema Schema1.xsd not found in E:\usr\sap\DPI\DVEBMGS40\j2ee\cluster\server0\validation\schema\f7cd3b50a87411e08830ed9d0af006a5\urnstw.contractor.wfm.workorderretrieval\MaintenanceOrderByIDQueryRequest_Out\httpsap.comxiEA-APPLSEGlobal\Schema1.xsd (validation\schema)
at com.sap.aii.adapter.soap.ejb.XISOAPAdapterBean.process(XISOAPAdapterBean.java:1041)Hi,
We are having the same problem, so you are not alone.
I had an extensive call with Azure premium support and we where able to determine that:
- Nothing is missing or in the wrong place in my exported .xml file.
- Any changes to the VNET's using the web gui interface of https://manage.windowsazure.com is not possible when you have dns servers and use an gateway
- You can download the .xml configuration file of the network and make manual changes to it, then import it again , to add/remove dns servers and or subnet's.
I am currently waiting for an solution, i have let them lower the urgency from A to B (because i can make changes trough xml) and responded to the next support contact (saying he will continue with the issue) that the problems seems to be with azure and
he should speak with the previous person helping me. I have not heard from Azure support since.
SR Number:115021812414226
Open on:02/18/2015 09:28
> There are networks with and without gateways created and the issue is happening on all the networks.
> We are unable to add or remove the DNS servers. (by web gui)
> Also not able to add or remove any subnets. (by web gui)
> Every time the error message is same but the DNS server name is different. (from another subnet then the one we are changing)
> Created CRI- 3405931, but they said it will need WATS team.
> Confirmed with WATS engineer as well and moving case to WATS.
> Cx agreed to lower the severity of the case as they are able to make changes through the network configuration file.
> But they still want to get this resolved soon.
> Agreed and dropped off, reducing severity to B 24/7.
I hope microsoft is going to resolve this soon, as i do not want to edit my xml for little things like adding a subnet all the time. I have requested an status update in the issue.
Should anyone have more information on this, please share it here. -
XML Schema validation error in network configuration. Missing DnsRef
When ever we try to make changes to a Virtual network we receive
XML Schema validation
error in network configuration. Missing DnsRef
We can't make any changes to the Virtual network.
The DNS ref exists as well.
Considering exporting network config and re-importing however we have a lot of networks configured and want to be sure this is the correct way to proceed.
Any feedback much appreciated.
ThanksHi,
We are having the same problem, so you are not alone.
I had an extensive call with Azure premium support and we where able to determine that:
- Nothing is missing or in the wrong place in my exported .xml file.
- Any changes to the VNET's using the web gui interface of https://manage.windowsazure.com is not possible when you have dns servers and use an gateway
- You can download the .xml configuration file of the network and make manual changes to it, then import it again , to add/remove dns servers and or subnet's.
I am currently waiting for an solution, i have let them lower the urgency from A to B (because i can make changes trough xml) and responded to the next support contact (saying he will continue with the issue) that the problems seems to be with azure and
he should speak with the previous person helping me. I have not heard from Azure support since.
SR Number:115021812414226
Open on:02/18/2015 09:28
> There are networks with and without gateways created and the issue is happening on all the networks.
> We are unable to add or remove the DNS servers. (by web gui)
> Also not able to add or remove any subnets. (by web gui)
> Every time the error message is same but the DNS server name is different. (from another subnet then the one we are changing)
> Created CRI- 3405931, but they said it will need WATS team.
> Confirmed with WATS engineer as well and moving case to WATS.
> Cx agreed to lower the severity of the case as they are able to make changes through the network configuration file.
> But they still want to get this resolved soon.
> Agreed and dropped off, reducing severity to B 24/7.
I hope microsoft is going to resolve this soon, as i do not want to edit my xml for little things like adding a subnet all the time. I have requested an status update in the issue.
Should anyone have more information on this, please share it here. -
Hi everybody
Look at the following simple xml schema:
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org"
targetNamespace="http://www.example.org"
elementFormDefault="qualified">
<xsd:element name="num" type="xsd:string"/>
<xsd:element name="amount" type="xsd:integer"/>
<xsd:element name="invoice">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="num"/>
<xsd:element ref="amount"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="invoices">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="xsd:invoice" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
When I open it in JDeveloper 10.1.3.2.0 and choose "Validate XML", validation executes without errors.
In spite of bad namespace declaration in <xsd:element ref="xsd:invoice" ...
For example, in XML Spy validation of this schema ends with error: "'xsd:invoice' must refer to an existing element".
If there any option on JDeveloper to turn on namespace-aware validation to prevent the above situation?hi
Indeed, the "Validate XML" menu option only shows "Validate XML: 0 errors, 0 warnings.".
But, if you look at the "Design" tab for your schema, the "invoices" element node contains an "xsd:invoice" sequence shown in red. If you change "xsd:invoice" to "invoice" this becomes white and the node can be expanded.
One other thing, registering an XML Schema in JDeveloper like the one you posted, isn't possible without an "oracle.xml.parser.schema.XSDException" (without further details).
regards
Jan Vervecken -
How to display transformed XML in flex? xslt processor w/o javascript?
I have a tree view with a list of links. upon clicking the links it will display its contents in an iFrame.
some of the links in my tree are, google.com, yahoo.com, and 2 xml files, 1 of which i have transfromed into html using xsl.
google, yahoo and the xml file which i have not transformed display successfully in the iFrame. however the xml which i have transformed does not display anything. is there another way to display html in flex? or is there a way to display a transformed xml to html in flex.
also is there another way to to use an xslt processor in flex without having to use javascript?In jsp page set content type to text/xml
<%@ page contentType="text/xml" %> -
Transformation XML problem.
Hello!
I have very easy java code for transform XML document (sorry, for print out XML without changes):
parser = new DOMParser();
parser.setPreserveWhitespace(false);
// parser input XML file
xmlURL = createURL(args[0]);
parser.parse(xmlURL);
xml = parser.getDocument();
// print the transformed document
xml.print(System.out);
But if I have DTD in XML then JDK write many errors: SIGBUS 10* bus error
If XML does not contains DTD then java code work successfuly.
I use JDK 1.2.2, xmlparserv2 for Sun SolarisTry turning off your JIT.
I've only ever seen core dumps when it was a JIT problem. -
JAXP, XML without SchemaLocation against Schema
I have problems with JAXP
I have been checking samples JAXP in next URL:
http://xml.apache.org/~edwingo/jaxp-ri-1.2.0-fcs/docs/samples.html
I have
- request.xml (on bottom)
- http://www.oasis-open.org/committees/security/docs/cs-sstc-schema-protocol-01.xsd
My XML validation don't use xsi:hints in instance document
my cmd> java DOMEcho -xsdss http://www.oasis-open.org/committees/security/docs/cs-sstc-schema-protocol-01.xsd request.xml
ERROR:
java.lang.StackOverflowError
at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:575)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:489)
at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:588)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:489)
at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:588)
Can anybody send me one document xml without xsi:hints and its XML Schema for check this examples???
request.xml
<samlp:Request IssueInstant="2002-07-09T13:56:41Z" MajorVersion="1" MinorVersion="0" RequestID="62.36.95.97.1026223001110" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol">
<samlp:AssertionArtifact>AAEQg2E01sLUvoGL7jo0gkrf3lw3lQAAAAAAAAAAAAAAANUDN5LCBWe5</samlp:AssertionArtifact>
</samlp:Request>Has anyone solved this problem?
I'm facing exact same one!
Please, help!
Vadim. -
Parse document without validating
Hi all,
I'm writing a program which will be run in a stand alone machine (i.e. no network connection). When I parse my document which contain a "DOCTYPE", it will have an exception. Also, I don't want to store the DTD file in my local machine. How can I parse a document without validating it in a SAXParser? Thx for all.
Here is my parser code:
SAXParserFactory factory = SAXParserFactory.newInstance();
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.setContentHandler(new SaxParser());
reader.parse(xml_file);
In the XML document:
<!DOCTYPE package PUBLIC "+//ISBN....." "http://abc.org/dtd.....">
The exception is:
java.net.UnknownHostException: abc.orghow about this code?
SAXParserFactory factory = SAXParserFactory.newInstance();
//disable validation
factory.setValidating(false);
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.setContentHandler(new SaxParser());
reader.parse(xml_file); -
I had Acrobat Standard 9.5 on a laptop that broke. Adobe Acrobat Standard is paid for and all I need. I had to get a new PC (Windows 8.1) and I did downloaded Standard 9.5 but when I went to install it the installer gave me an “Error applying transforms please ensure specified transform paths are valid”. Any ideas on how to fix this?
Rahul,
No error numbers other than the message I mentioned previously.
I tried the transforms repair and it reported no Acrobat product (correct, none yet installed) or no administrative privileges (I am the administrator and have done previous administrative actions).
When I unzip the Acrobat file this is what is in the setup ini file:
[Startup]
RequireOS=Windows XP
RequireMSI=3.0
RequireIE=6.0.2600.0
[Product]
msi=AcroStan.msi
Languages=1033;1031;1036
1033=English (United States)
1031=German (Germany)
1036=French (France)
CmdLine=TRANSFORMS="AcroStan.mst"
[Windows XP]
PlatformID=2
MajorVersion=5
MinorVersion=1
ServicePackMajor=2
[MSI Updater]
Path=WindowsInstaller-KB893803-v2-x86.exe
Thoughts?
Thanks again,
Tom
Maybe you are looking for
-
Tracking Sub contracting Purchase Order
Hi , We have a Subcontracting Purchase Order. The users have created a delivery from ME2O and PGied it. They have forgot the PO number for which they have created the delivery and PGied.. How can we track the subcontracting PO if we know the LB deliv
-
Adobe myth on nondestructive editing!!!
Recently shifted from RAW+XMP combination (when it was easy just to kill XMP) to DNG format in CS3. Unfortunately discovered that crop or retouch actions under ACR4.1 with DNG files are NON REVERSIBLE. Lost several nice shoots :( Be careful!
-
Skype premium with unlimited world account but cal...
I've been subscribed to Skype premium with unlimited world for a long time now, then just got an email a few days ago, saying I got a free upgrade, and now I can't make any calls - tells me I have to 'buy credit' every time I try making any call I us
-
Deleting languages in 10.4.0
I had to reinstall 10.4.0 on a G4 and the installer wouldn't let me uncheckthe languages option. How can I delete them now. There are >800 Mb, andI could use the space. Plus, I don't speak Finnish:)
-
HT6114 Help, I accidently deleted the app store
As a result I cant do updates, find my contacts, calendar, etc. How can I reinstall? I'm currently running OS X 10.9.2 on my Macbook Pro that I purchased a little over a year ago. Any help would be greatly appreciated.