Validate XML against XSD with imported xsd's
Hello,
I'm stuck for a while attempting to validate a xml against some xsd's. In the code below you can find my xsd's structure: (I need to use this structure in order to reuse the baseXsd's files.
CommonTypes.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CommonTypes" targetNamespace="http://test.com/CommonTypes"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:simpleType name="NonEmptyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
CommonLog.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CommonLogConfig"
targetNamespace="http://test.com/CommonLogConfig"
xmlns:cmn="http://test.com/CommonTypes"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:import schemaLocation="..\Base\CommonTypes.xsd" namespace="http://test.com/CommonTypes" />
<xs:simpleType name="LogName">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="LogPath">
<xs:restriction base="cmn:NonEmptyString"/>
</xs:simpleType>
</xs:schema>
LogConfig.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:mlc="http://test.com/CommonLogConfig"
targetNamespace="component1_LogConfig"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:import schemaLocation="..\Base\CommonLogConfig.xsd" namespace="http://test.com/CommonLogConfig" />
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="default">
<xs:complexType>
<xs:all>
<xs:element name="LogName" type="mlc:LogName" fixed="component.name" />
<xs:element name="LogPath" type="mlc:LogPath"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
LogConfig.xml
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="component1_LogConfig">
<default>
<LogName>component.name</LogName>
<LogPath></LogPath>
</default>
</root>
As you can probably notice, the <LogPath> key on the LogConfig is empty, but, it is defined as a NonEmptyString type. That is the way I'm validating the xml against xsd:
FileStream stream = new FileStream("LogConfig.xml", FileMode.Open);
XmlValidatingReader vr = new XmlValidatingReader(stream, XmlNodeType.Element, null);
vr.Schemas.Add(null, "LogConfig.xsd");
vr.ValidationType = ValidationType.Schema;
vr.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
while (vr.Read()) ;
The validationCallBack is not being fired.
I suppose it is possible since the visual studio show me the error at compile time:
Well, it is weird, but, the code below works when validating the NonEmptyString type:
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(null, "LogConfig.xsd");
XDocument doc1 = XDocument.Load("LogConfig.xml");
doc1.Validate(schemaSet, new ValidationEventHandler(ValidationCallBack), false);
However, if I leave the <LogName> empty it does not valid the values set on xsd fixed attribute,
The solution?
Well, I'm validating the same xml twice, the code above and the code on my first question.
Similar Messages
-
How to validate XML against XSD and parse/save in one step using SAXParser?
How to validate XML against XSD and parse/save in one step using SAXParser?
I currently have an XML file and XSD. The XML file specifies the location of the XSD. In Java code I create a SAXParser with parameters indicating that it needs to validate the XML. However, SAXParser.parse does not validate the XML, but it does call my handler functions which save the elements/attributes in memory as it is read. On the other hand, XMLReader.parse does validate the XML against the XSD, but does not save the document in memory.
My code can call XMLReader.parse to validate the XML followed by SAXParser.parse to save the XML document in memory. But this sound inefficient. Besides, while a valid document is being parsed by XMLReader, it can be changed to be invalid and saved, and XMLReader.parse would be looking at the original file and would think that the file is OK, and then SAXParser.parse would parse the document without errors.
<Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd" name="MyBook">
<Chapter name="First Chapter"/>
<Chapter name="Second Chapter">
<Section number="1"/>
<Section number="2"/>
</Chapter>
</Book>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Book">
<xs:complexType>
<xs:sequence>
<xs:element name="Chapter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Section" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="xnumber"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:schema>
public class SAXXMLParserTest
public static void main(String[] args)
try
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
SAXParser parser = factory.newSAXParser();
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
BookHandler handler = new BookHandler();
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(handler);
parser.parse("xmltest.dat", handler); // does not throw validation error
Book book = handler.getBook();
System.out.println(book);
reader.parse("xmltest.dat"); // throws validation error because of 'xnumber' in the XSD
public class Book extends Element
private String name;
private List<Chapter> chapters = new ArrayList<Chapter>();
public Book(String name)
this.name = name;
public void addChapter(Chapter chapter)
chapters.add(chapter);
public String toString()
StringBuilder builder = new StringBuilder();
builder.append("<Book name=\"").append(name).append("\">\n");
for (Chapter chapter: chapters)
builder.append(chapter.toString());
builder.append("</Book>\n");
return builder.toString();
public static class BookHandler extends DefaultHandler
private Stack<Element> root = null;
private Book book = null;
public void startDocument()
root = new Stack<Element>();
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
if (qName.equals("Book"))
String name = attributes.getValue("name");
root.push(new Book(name));
else if (qName.equals("Chapter"))
String name = attributes.getValue("name");
Chapter child = new Chapter(name);
((Book)root.peek()).addChapter(child);
root.push(child);
else if (qName.equals("Section"))
Integer number = Integer.parseInt(attributes.getValue("number"));
Section child = new Section(number);
((Chapter)root.peek()).addSection(child);
root.push(child);
public void endElement(String uri, String localName, String qName) throws SAXException
Element finished = root.pop();
if (root.size() == 0)
book = (Book) finished;
public Book getBook()
return book;
public void error(SAXParseException e)
System.out.println(e.getMessage());
public void fatalError(SAXParseException e)
error(e);
public void warning(SAXParseException e)
error(e);
public class Chapter extends Element
public static class Section extends Element
private Integer number;
public Section(Integer number)
this.number = number;
public String toString()
StringBuilder builder = new StringBuilder();
builder.append("<Section number=\"").append(number).append("\"/>\n");
return builder.toString();
private String name;
private List<Section> sections = null;
public Chapter(String name)
this.name = name;
public void addSection(Section section)
if (sections == null)
sections = new ArrayList<Section>();
sections.add(section);
public String toString()
StringBuilder builder = new StringBuilder();
builder.append("<Chapter name=\"").append(name).append("\">\n");
if (sections != null)
for (Section section: sections)
builder.append(section.toString());
builder.append("</Chapter>\n");
return builder.toString();
}Edited by: sn72 on Oct 28, 2008 1:16 PMHave you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.
-
How to Validate XML against XSD through PL/SQL?
Hi friends,
I m new to this forum. This is my first query.
In our project, we are trying to generate output XML using PL/SQL procedure. I have done that successfully. Now my problem is I have to validate this against our XSD. How will I do that? Can you provide me with a sample example.
Thanks to all in advance.
Regards,
apkHave you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.
-
HOW TO USE isSchemaValid() in oracle 9i to validate XML against XSD
Hi
I am trying to validate xml file against xsd in oracle 9i.The steps are as follows:
*1.Created directory for xml and xsd file location:*
CREATE or replace DIRECTORY XML_DATA AS 'D:\prod\sample xml and xsd;
*2.Register the schema*
DECLARE
bf5 BFILE;
BEGIN
-- Register the schema
dbms_lob.filecloseall;
bf5 := BFILENAME('XML_DATA','xml1.xsd');
DBMS_XMLSCHEMA.registerSchema('http://www.example.com/schemas/ipo.xsd',bf5,TRUE, TRUE, FALSE,TRUE,TRUE);
-- dbms_lob.fileclose(bf5);
END;
*3.creatibg table to store xml files*
CREATE TABLE po_tab2 (id NUMBER,xmlcol SYS.XMLType) ;
*4.Inserting xml file into the table and validating that file with xml schema*
declare
aa clob:=' ';
b varchar2(4000);
c xmltype;
begin
dbms_lob.filecloseall;
aa:= GETCLOBDOCUMENT('XML_DATA','example.XML','WE8MSWIN1252');
INSERT INTO po_tab2 (ID, XMLCOL)
VALUES
(104,sys.XMLType.createXML(aa));
commit;
--c:=sys.xmltype.createXml(aa);
c:=xmltype(aa);
b:=VerifyXML(c,'http://www.example.com/schemas/ipo.xsd');
dbms_output.put_line(b);
end;
_5.VerifyXML function is:_
create or replace
function VerifyXML( xml xmltype, xmlSchema varchar2 ) return varchar2 AUTHID DEFINER is
xmlURL varchar2(4000);
begin
select
s.qual_schema_url into xmlURL
from user_xml_schemas s
where s.schema_url = xmlSchema;
if xml.isSchemaValid(xmlURL,'ManageRolloutRegionNotification') =1 then
return( 'Valid. The supplied XML complies with XSD '||xmlURL );
else
-- return null;
return(sqlcode|| 'Failed. The supplied XML does not comply with XSD '||xmlURL );
end if;
exception when others then
return(sqlcode);
end;
_6.PROBLEM:_
the problem is the function is always returning 'Failed ' status even though I am giving the correct file.. Is there any method to find the reason for failure. These codes are working fine oracle 11g. currently i am working in 9i version 9.2.0.1.0. IOracle 9iR2 is not supported anymore.
Oracle 9.2.0.8 is in sustained support.
Oracle 9.2.0.1 is not supported at all.
Upgrade to 11gR2.
Sybrand Bakker
Senior Oracle DBA -
Validate XML against XSD using PLSQL
Hi,
We now need some kind of automated solution that will pick
up the XMLs from a specific location or table and validate them
against the XSD in only Oracle PLSQL.
The validation of the XML against the XSD should take place when the XML is parsed.
I want to know how first the XSD's are stored or registered in the Oracle XDB repository.
Please can anyone suggest me how this can be done with a simple example
with a sample XML and XSD?
Regards,
Marlon.Hi, I'm not an expert but I've been reading a lot and I found this and it works. I'll hope it is useful.(Oracle 10)
declare
-- Local variables here
res BOOLEAN;
tempXML XMLType;
xmlDoc XMLType;
xmlSchema XMLType;
schemaURL varchar2(256) := 'testcase.xsd';
schemaPath varchar2(256) := '/public/testcase.xsd';
begin
dbms_xmlSchema.deleteSchema(schemaURL,4);
-- Test statements here
xmlSchema := xmlType(
'<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="root" xdb:defaultTable="ROOT_TABLE">
<xs:complexType>
<xs:sequence>
<xs:element name="child1"/>
<xs:element name="child2"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
dbms_xmlschema.registerSchema(schemaURL,
xmlSchema , --xdbURIType(schemaPath).getClob(),
TRUE,TRUE,FALSE,TRUE
xmlDoc:=xmltype('<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="' || schemaURL || '"><child1>foo</child1><child2>bar</child2></root>');
dbms_output.put_line(xmlDoc.getStringVal());
xmlDoc.schemaValidate();
END; -
Error in XSD Parsing - Imported XSD not being loaded
I am trying to validate XML with XSD. The XML has elements in two different namespaces:-
1-"http://schemas.xmlsoap.org/soap/envelope/"
2-urn:Hotel_Reserve
So in Schema I have defined elements Envelop, Header and Body in "http://schemas.xmlsoap.org/soap/envelope/" namespace and targetNamespace and imported another schema which is in "urn:Hotel_Reserve" namespace. Here it is:-
<xs:schema xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n1="urn:Hotel_Reserve" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" elementFormDefault="qualified">
*<xs:import namespace="urn:Hotel_Reserve" schemaLocation="BookingRequestBody.xsd"/>*
<xs:element name="Envelope">
<xs:complexType>
<xs:sequence>
<xs:element name="Header">
<xs:complexType/>
</xs:element>
<xs:element name="Body">
<xs:complexType>
<xs:sequence>
*<xs:element ref="n1S_HotelRes_RQ"/>*
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I am using JDK1.5. I am able to validate the XML in a standalone Java program. I suppose here the Xerces parse is being used which is shipped with JDK itself in com.sun.org.apache.xerces* package.
The problem is when the same code is deployed in JBoss 4.0.3SP1, I get following exception:-
org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'n1S_HotelRes_RQ' to a(n) 'element declaration' component.
It seems that when the code is deployed in JBoss, and the main XSD(which is mentioned above) is loaded and parsed, the schema in the import section is not loaded. I have checked the schema are present in the required place.
Any clue where I may be doing wrong?Instead of parsing the schema with DOM/SAX, just loading it with URL worked with JBoss.
But I dont know how and why?
here is the sample code:
URL schemaURL = Thread.currentThread().getContextClassLoader().getResource(WSConstants.BOOKING_SCHEMA_FILE);
SchemaFactory provBookingSchemaFactory = schemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); provBookingSchemaFactory.setErrorHandler(new InvalidXMLErrorHandler());
Schema provBookingSchema = provBookingSchemaFactory.newSchema(schemaURL);
Validator provBookingValidator = provBookingSchema.newValidator();
provBookingValidator.validate(new DOMSource(requestDoc));
Earlier I was creating the schema instance using the DOM source:-
Schema provBookingSchema = provBookingSchemaFactory.newSchema(new DOMSource(schemaDoc)); -
Can not validate XML against schema
Hi all,
I'm new to XML validation. I have this sample from net.
this is the schema definition:
<xs:schema targetNamespace="http://www.w3schools.com" elementFormDefault="qualified">
<xs:element name="note" type="xs:string"/>
</xs:schema>
and this is the xml file:
<?xml version="1.0"?>
<note xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
when i try to validate at http://schneegans.de/sv/, this is a validator i found searching
it gives error
The root element does not comply with the schema. (2:2)
any ideas?
i have created my own xml and schema.I registered the xsd on oracle 10g but i get the same error :(
where can i validate my xml against a schema?
thanx a lotValidating XML Documents Against XML Schema
http://www.oracle.com/technology/pub/articles/vohra_xmlschema.html -
Validate XML against XML Shema while marshalling/Unmarshalling in JAXB?.
Hi,
Can i validate XML documents against XML Shema when i marshall/unmarshall the same using JAXB API?.
ThanksWell, it is weird, but, the code below works when validating the NonEmptyString type:
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(null, "LogConfig.xsd");
XDocument doc1 = XDocument.Load("LogConfig.xml");
doc1.Validate(schemaSet, new ValidationEventHandler(ValidationCallBack), false);
However, if I leave the <LogName> empty it does not valid the values set on xsd fixed attribute,
The solution?
Well, I'm validating the same xml twice, the code above and the code on my first question. -
Validate XML against Xml Schema using JDBC (thin_driver)
hi all,
i have a table with a xmltype-column (XmlSchema Support) and i wonna load(and validate) xml-data( as String) in the xmltype-column.
some thing like this :
int count=1;
String SQLTEXT=null;
Statement stmt=null;
ResultSet rs =null;
//while(count<=1000)
try
stmt = connection.createStatement();
rs = stmt.executeQuery("select SEQ_patxmlschema_ID.NEXTVAL from patxmlschema");
if(rs.next())
id =rs.getLong(1);
System.out.println(id);
stmt.close();
stmt=null;
rs.close();
SQLTEXT = "INSERT INTO patxmlschema(id, patID, name, status, patInfo)"+
"VALUES(?,?,?,?,XMLType(?))";
pStmt = connection.prepareStatement(SQLTEXT);
long patID = random.nextInt(30000);
System.out.println("patId: "+ patID);
String name = RandomStringUtils.random(6,true,false);
System.out.println("lastname: "+ name);
String firstname=RandomStringUtils.random(5,true,false);
System.out.println("firstname: "+ firstname);
String status=RandomStringUtils.random(8,true,false);
System.out.println("status: "+ status);
String street=RandomStringUtils.random(6,true,false);
System.out.println("street: "+ street);
String zip=RandomStringUtils.random(5,false,true);
System.out.println("zip: "+ zip);
String city=RandomStringUtils.random(6,true,false);
System.out.println("city: "+ city);
String phone=RandomStringUtils.random(8,false,true);
String email=RandomStringUtils.random(15,true,false);
String state=RandomStringUtils.random(6,true,false);
String country=RandomStringUtils.random(6,true,false);
System.out.println("country: "+ country);
xmldoc=
"<Patient>"+ "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+ "xsi:noNamespaceSchemaLocation='http://olidong.net/patInfo.xsd'>"+
"<Address>"+ "<street>"+street+"</street>"+ "<city>"+city+"</city>"+ "<zip>"+zip+"</zip>"+
"<state>"+state+"</state>"+ "<country>"+country+"</country>"+
"</Address>"+ "<phone>"+phone+"</phone>"+ "<email>"+email+"</email>"+
"</Patient>";
pStmt.setLong(1, id);
pStmt.setLong(2, patID);
pStmt.setString(3, name);
pStmt.setString(4, status);
pStmt.setString(5, xmldoc);
pStmt.executeUpdate();
pStmt.close();
pStmt=null;
count++;
//connection=null;
catch(Exception e){
e.printStackTrace();
can you help me?
Olidonghi Avi,
my xml doc is valid. with the sqlplus the are no problem or error. tryng the same with jddbc(thin driver) i got this error.
i don´t know, may be jdbc don´t support xml schema support insertion.
i got this sample:
DECLARE
doc VARCHAR2(2000) :=
'<schema
targetNamespace="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
xmlns:po="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<complexType name="PurchaseOrderType">
<sequence>
<element name="PONum" type="decimal"/>
<element name="Company">
<simpleType>
<restriction base="string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element name="Item" maxOccurs="1000">
<complexType>
<sequence>
<element name="Part">
<simpleType>
<restriction base="string">
<maxLength value="20"/>
</restriction>
</simpleType>
</element>
<element name="Price" type="float"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
<element name="PurchaseOrder" type="po:PurchaseOrderType"/>
</schema>';
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd', doc);
END;
CREATE TABLE mypurchaseorders OF XMLType
XMLSchema "http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
ELEMENT "PurchaseOrder"
VARRAY xmldata."Item" STORE AS TABLE item_nested;
INSERT INTO mypurchaseorders
VALUES(
XMLType(
'<PurchaseOrder
xmlns="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
= "http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd
http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd">
<PONum>1001</PONum>
<Company>IBM</Company>
<Item>
<Part>DB2 v9 Set</Part>
<Price>2550</Price>
</Item>
<Item>
<Part>8i Doc Set</Part>
<Price>350</Price>
</Item>
</PurchaseOrder>'));
with the sqlplus the are no error
but insert with java jdbc:
SQLTEXT = "INSERT INTO mypurchaseorders VALUES(XMLType(?))";
String xmldoc= "<PurchaseOrder"+
"xmlns='http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'" +
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
"xsi:schemaLocation= 'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'"+
"'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'>"+
"<PONum>1001</PONum>"+
"<Company>IBM</Company>"+
"<Item> "+
"<Part>DB2 v9 Set</Part>"+
"<Price>2550</Price>"+
"</Item>"+
"<Item>"+
"<Part>8i Doc Set</Part>"+
"<Price>350</Price>"+
"</Item>"+
"</PurchaseOrder>";
pStmt.setString(1, xmldoc);
i got this error
java.sql.SQLException: ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00240: element-start tag is not well formed
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at xml_tab.doInsert(xml_tab.java:118)
at xml_tab.main(xml_tab.java:138)
could you help me?
Olidong -
How to validate XML against Schema
Hi,
I am trying to validate the XML against the schema by using follywing code but i am never getting errors in parser it always passes the parser even though there are serious parsing problems. My code is as follows:
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser sp = spf.newSAXParser();
sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdPath);
DefaultHandler dh = new DefaultHandler();
sp.parse(splObjPath, dh);
thanksMany ways to do this... also depending upon what version of Xerces and/or you want to do DTD or schema, etc one of the simplest is to set the following properties,
refer to:
http://xerces.apache.org/xerces2-j/features.html
Scroll down, check all the features starting with "http://apache.org/xml/features/validation" -
How to validate XML Digital Signature with XML DB (o PL/SQL) in Oracle 11g
Hi,
Do you know if there is possibility to validate XML Digital Signature using XML DB (or PL/SQL) in Oracle 11g?
Let say I have CLOB/XMLType containing Digitally Signed XML, and I want to validate, that thsi is proper signature. I also have public key of signer (I could store it in CLOB or file or Oracle wallet).
Is it possible to do?
If there is need to install additional component - then which one?
Regards,
PawełHi,
this is what i got from someone...
but the links he gave are not opening up...
u have to place a picture there and have to load the digital signatures as Jpegs on to the server to OA top
and have to refer them in the XML for dynamically get the signature on the reports
when u select the properties of the picture placed in the XML template,
there will be one tab with "URL"... in that u have to give the path for that jpegs
Pls refer the following documents for enabling digital signature on pdf documents.
http://iasdocs.us.oracle.com/iasdl/bi_ee/doc/bi.1013/e12187/T421739T481159.htm#5013638 (refer section 'Adding or Designating a Field for Digital Signature'
http://iasdocs.us.oracle.com/iasdl/bi_ee/doc/bi.1013/e12188/T421739T475591.htm#5013688
(Implementing a Digital Signature
Is the BI Publisher installed on your instance of version 10.1.3.4 or higher?
Pls procure a digital signature as soon as possible. The process can take time. OR we could use any certificate that you already might have OR generate a certificate using Oracle Certificate Authority for demo. -
Hello
I have several XML files and into this XML files there is not th DTD call.
i have another file, the DTD.
There is any method or code example for, without modify the XML files for including the DTD call, validate the XML againts one DTD?
thanksAlice (guest) wrote:
: Hi! I have obtained the v2 parser for java and the one for
plsql.
: I want to validate xml documents against a DTD file provided
by
: another program. I can't find any sample code that does setDTD
: for validation.
: Can you tell me how it can be done, please?
: Thanks in advance!
The method to set the DTD is setDoctype().
Stub code follows:
// Test using InputSource
parser = new DOMParser();
parser.setErrorStream(System.out);
parser.showWarnings(true);
FileReader r = new FileReader(args[0]);
InputSource inSource = new InputSource(r);
inSource.setSystemId(createURL(args[0]).toString());
parser.parseDTD(inSource, args[1]);
dtd = (DTD)parser.getDoctype();
r = new FileReader(args[2]);
inSource = new InputSource(r);
inSource.setSystemId(createURL(args[2]).toString());
parser.setDoctype(dtd);
parser.setValidationMode(true);
parser.parse(inSource);
doc = (XMLDocument)parser.getDocument();
doc.print(new PrintWriter(System.out));
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
How can we validate a XML against his external schema XSD
Hi;
I use the XML library for create my XML file, Im extracting the data
from R3 and building the XML document.
I wish to validate this document against his schema XSD built by third party (government organization) before i transfer this data (xml file)
to the external entity.
In my abap program:
¿How can i reach this validation level and if any
error exists then how can i get or trap the detail information?
this is a sample file XML with the external schema reference, as you can see in this part of the code.
<?xml version="1.0" encoding="UTF-8" ?>
- <Comprobante xmlns="http://www.sat.gob.mx/cfd/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/2 http://www.sat.gob.mx/sitio_internet/cfd/2/cfdv2.xsd" version="2.0" serie="A" folio="0000238" fecha="2006-09-01T19:32:03-05:00" sello="o4kAzhytaTKThSk9tbTQGg5OGacAltWZwxQPZuMg1XhfjMq5jJ0GyO7w2//bf8aTuHnbqwpkR7rIgIehGLy88Xb3Ck0EDsWZEAC1QUuqRq2iWKAnGQPS4l9s0QrJHt0Ziojjd0GQFek6BYXPdlmdTjLZ2x+J8ffYEGpIQZRB8=" noAprobacion="2755" anoAprobacion="2006" formaDePago="En una sola exhibicion" noCertificado="00001000000000806462" condicionesDePago="Neto a 30 días sin DPPP" subTotal="2531.99" descuento="0.00" total="2912.90" tipoDeComprobante="ingreso">
<DomicilioFiscal calle="AVE. UNIVERSIDAD" noExterior="992 NTE." colonia="COL. CUAUHTEMOC" municipio="SAN NICOLAS DE LOS GARZA" estado="N.L." pais="MEXICO
We are using SAP R/3 46C
Thanks in Advance for your help.
Alejandro PérezHi, Alejandro
Did you found something on SAP side in order to generated this XML.
Currently I´m trying to find out some on SAP but nothing at this moment.
The company that I´m working needs to implement "Factura Electonica" also.
Probably we will use external broker to do this for us, and we will send just Idoc to the broker.
Please, let me know your progress on SAP side.
Regards, Fabio -
Hi. I need to validate an XML file against XSD schema.
How can I do it with PL/SQL?
Thanks a lot
AlejandroWell, it is weird, but, the code below works when validating the NonEmptyString type:
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(null, "LogConfig.xsd");
XDocument doc1 = XDocument.Load("LogConfig.xml");
doc1.Validate(schemaSet, new ValidationEventHandler(ValidationCallBack), false);
However, if I leave the <LogName> empty it does not valid the values set on xsd fixed attribute,
The solution?
Well, I'm validating the same xml twice, the code above and the code on my first question. -
Webservice from WSDL with imported XSD
Hi all,
Firstly, as a newbie to Jdeveloper forgive the ignorance....
I'm trying to create and deploy a webservice (created top-down).
I have an XSD, and a WSDL which imports this via a relative reference of the kind ../../ etc. - this validates OK in JDeveloper
When I try to deploy this to WL I get a file not found error for this XSD, it can't find the XSD in the packaged archive to be deployed.
So my question, for the import statement in my WSDL which is currently....
<xsd:import namespace="http://xml.netbeans.org/schema/LoanApplication" schemaLocation="../../../LoanApprover.xsd"/> (i.e. XSD directory relative to WSDL directory at design time)
...what do I need to change it to so that when packaged it can find the XSD ?
Thanks in advance
MarkFSolved on JDeveloper forum.
Maybe you are looking for
-
Move to first record of ref curser after fetch
I have the following package (v2 is not used in this example): CREATE OR REPLACE PACKAGE test_ref_cursor AS TYPE gc IS REF CURSOR; PROCEDURE test_ref_cursor(v1 OUT gc ,v2 IN VARCHAR2 ,v3 OUT VARCHAR2); END; CREATE OR REPLACE PACKAGE BODY test_ref_cur
-
USB Webcam when using Bootcamp to run WindowsXP?
Is it possible to use an external webcam, e.g., Logitech's, and able to use it on the iMac running WindowsXP with Bootcamp? I'm planning to use it with MSN Messanger 7.5. Thanks. I just wish that Microsoft will come out with a crossplatform Messanger
-
OIM 11g: OIM User "Notes" field
Does anyone know if anything has changed from 9.1x to 11g with regard to the Users.Note attribute? We have a unit test that reads and tries to set "Users.Note" via the tcUserOperationsIntf.updateUser() method. This test works fine against OIM 9.1x, b
-
Coldfusion / Javascript Issue
This probably is not the most appropriate place to post this, but I am sure that people that frequent these forums have run into this: i am making an edit form. the form will allow users to update a record in teh database. --here are parts of the cod
-
Is there anyway to call a method in Controller.jpf from a jsp page? I want to have my jsp page call a method from the jpf controller through an onChange event in the select tag. Otherwise I will have to write a large amount of javascript directly int