|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Validate XML Documents
Author: Massimo, Tiziana e Federica
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161383
The JRE 1.4.2 that ships with CF 6.1 doesn't include XSD validation as part
of its APIs. You can install and use another XML parser to do the job
(Xerces is the first that comes to mind)
You already got suggestion about the code required, the topic is covered
very well here:
http://www.ibiblio.org/xml/books/xmljava/chapters/ch07s04.html#d0e10881
----------------------------
Massimo Foti
http://www.massimocorner.com
Co-Author of Dreamweaver MX 2004 Magic:
http://www.dwmagic.com/
Author: Rob
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161379
Here is a good blurb on how to do it in java - pretty similar steps in
cf
http://www.geocities.com/herong_yang/jdk/xsd_validation.html
On Mon, 2004-04-26 at 19:39, Rob wrote:
----- Excess quoted text cut - see Original Post for more -----
--
Rob <me@robrohan.com>
Author: Rob
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161378
On Mon, 2004-04-26 at 13:29, Troy Simpson wrote:
> All,
>
> Is there a ColdFusion Function to validate an XML Document against a its
> schema?
As far as I know the only java parser (last I heard anyway) that
validates with a schema is Xerces (which cf uses I think). However, I
don't think there is a standard, cross parser, way in java to do xsd
validation (unlike dtd) so there are not many java products that do xsd
validation yet.
This is quite a stretch as my cf sever is out of commission right now so
this is a totally untested code - but you could try something like:
<cfscript>
parser = CreateObject("java","org.apache.xerces.parsers.DOMParser");
//this might be needed...
//parser.init();
parser.setFeature("http://xml.org/sax/features/validation",
true);
parser.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"test.xsd"
);
parser.parse("test.xml");
</cfscript>
Look around on the www.apache.org site for xerces xsd validation, if cf
still uses it ... it might use Crimson ... some MM guy might chime in...
Good luck,
--
Rob <me@robrohan.com>
Author: Qasim Rasheed
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161374
I guess you can use Java XML parsers
Qaso,
Thanks for the response.
This only validates a formatted XML string against a DTD.
I need to validate the XML doc against an XSD.
Troy
Raymond Camden wrote:
> www.cflib.org/udf.cfm/validateXMLString
>
_____
Author: Raymond Camden
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161362
Ah, sorry about that.
Author: Troy Simpson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161359
Thanks for the response.
This only validates a formatted XML string against a DTD.
I need to validate the XML doc against an XSD.
Troy
Raymond Camden wrote:
> www.cflib.org/udf.cfm/validateXMLString
Author: Raymond Camden
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161358
www.cflib.org/udf.cfm/validateXMLString
Author: Troy Simpson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32158#161357
All,
Is there a ColdFusion Function to validate an XML Document against a its
schema?
Thanks,
--
Troy Simpson
Applications Analyst/Programmer, OCPDBA, MCSE, SCSA
North Carolina State University Libraries
Campus Box 7111 | Raleigh | North Carolina
ph.919.515.3855 | fax.919.513.3330
E-mail: Troy_Simpson@ncsu.edu
|
May 24, 2012
|
Latest Fusion Authority Articles
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||