Validate xml against xslt
i have a mapping with custom xslt. how to test against an input xml file?
how to debug the xslt by giving the input xml file as input?
Click on your map in Visual Studio Solution Explorer
Browse to your input xml file in the TestMap Input Instance property
Right click on your map in the solution Explorer and choose Test Map
In the output window, you can hold down ctrl and click on the link after The output is stored in the following file" to see the result.
You can also choose an output filename and path in the TestMap Output Instance property to have the file saved to a location of your own choosing.
Any errors will be displayed in the Error List in Visual Studio.
Depending on how strict you have it, you might need to disable the properties "Validate TestMap Input" and "Validate TestMap Output" when testing.
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.
-
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 -
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. -
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 -
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" -
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. -
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 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; -
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 -
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. -
Validate XML against DTD using PLSQL
Hi Friends,
I have an xml file and also a DTD, now I need to parse and validate this XML file against the DTD.
Please can anyone suggest me some examples or ways to do this.
NOTE: Only with Oracle not Java.
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 while Validating xml against a schema using jaxp
Hi All,
Following code validates xml against a schema using JAXP .It gives SAXNotRecognizedException error when you run the program.
static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
SAXParserFactory myFactory = SAXParserFactory.newInstance();
myFactory.setNamespaceAware(true);
myFactory.setValidating(true);
javax.xml.parsers.SAXParser parser;
String filename = "C:/Note.xml";
File xmlFile = new File(filename);
try
DefaultHandler handler = new DefaultHandler();
parser = myFactory.newSAXParser();
parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
parser.parse(xmlFile, handler);
catch (ParserConfigurationException e)
// TODO Auto-generated catch block
e.printStackTrace();
catch (SAXException e)
// TODO Auto-generated catch block
e.printStackTrace();
catch (IOException e)
// TODO Auto-generated catch block
e.printStackTrace();
Error Details :
org.xml.sax.SAXNotRecognizedException: http://java.sun.com/xml/jaxp/properties/schemaLanguage
at org.apache.xerces.framework.XMLParser.setProperty(XMLParser.java:1682)
at org.apache.xerces.parsers.SAXParser.setProperty(SAXParser.java:770)
at org.apache.xerces.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:183)
How do i fix the above mentioned problem ?
Thanks in Advance.
AnshValidate with the JAXP DOMParser instead of the JAXP SAXParser.
To validate with a SAXParser use the xerces SAXParser.
thanks,
Deepak -
Hi,
I would like to validate XML against XSD using SAX parser. Can any one help, where I can get information. I could get some information of XML validation against DTD. But could not get much information for XSD validation.
Which parser is good for validation against XSD? or shall I continue with SAX Parser?
KumaravelI use the "Summer 02 XML Pack" provided here at Sun, which is based on Xerces2 by Apache (http://xml.apache.org/xerces2-j/index.html). Actually with that, validation against schemas is pretty much like validation against DTDs, as long as the schema is referenced in your XML file and you switch on schema validation in the parser like
reader.setFeature("http://xml.org/sax/features/validation", true);
reader.setFeature("http://apache.org/xml/features/validation/schema", true);Xerces2 works both with DOM and SAX (I use SAX). You should browse Apache's website a bit. There's not too much information, but I guess it's enough to get started.
Maybe you are looking for
-
Web Services - WSDL doubt.
Hi all, Im sorry to repeat this subject again, but I continue with some doubts I read almost SDN web logs about web services. All they teach, how to configure and develop a simple web services but the steps to create a web service connection betwe
-
How can I change settings to stop my mobile from sending read receipts? I've turned it off in outlook (as far as I know), but when using my mobile this does not seem to work. Using intellisync and an E65. appreciate any advice E65
-
Installing Vista after replacing hard drive in a Toshiba Satellite L45-57423
The hard drive in my old Toshiba laptop went bad and had to be replaced. I no longer have (and am unsure I ever had) the Windows recovery disk. Do I need to purchase a new Windows Vista recovery disk for this computer or is it better to buy a Windows
-
I've had several users complain of receiving this message after they have filled out and submitted a form. There was an error communicating with the server. Click on the back button in you browser and try resubmitting the form. However the data is be
-
Has anyone ever asked Adobe to create a simpler version of Creative Suite? This would include: InDesign with no transparency or data merge. Think Pagemaker on OSX platform. Can place any files without transparency, and export straight to PDF. Illustr