jdomʵÏÖschemaÑéÖ¤xmlÎļþÊÇ·ñºÏ·¨
µ¼Èëjdom1.1°æ
http://www.jdom.org/dist/binary/
import java.io.FileReader;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
public class XMLValidate {
public void validate(String xml, String schema) {
try {
SAXBuilder builder = new SAXBuilder(true);
//Ö¸¶¨Ô¼Êø·½Ê½ÎªXML schema
builder.setFeature("http://apache.org/xml/features/validation/schema",true);
//µ¼ÈëschemaÎļþ
builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",schema);
Document doc = builder.build(new FileReader(xml));
System.out.println("¹§Ï²Äú£¬Ñé֤ͨ¹ý£¡£¡£¡");
}catch(Exception e) {
System.out.println("Ñé֤ʧ°Ü:"+e);
}
}
public static void main(String args[]) {
new XMLValidate().validate("e:\\a.xml","e:\\b.xsd");
}
}
Àϰ汾ÐèÒªÓõ½Xerces
²Î¼ûhttp://www.jdom.org/docs/faq.html#a0360
How do I validate against a schema when using JDOM?
JDOM doesn't have it's own parser; it uses standard parsers like Xerces to do the heavy lifting. If you want schema validation make sure you choose a parser that supports schemas. Xerces 2 is a good choice (get it from http://xml.apache.org). You also need to use code JDOM Beta 8 or later.
To specify the parser JDOM uses, you can either configure JAXP appropriately (since JDOM uses JAXP if it's available, see the end of this entry for details) or you can explicitly pass the name of the parser to the SAXBuilder constructor. For Xerces 2 the parser class is org.apache.xerces.parsers.SAXParser. You must also enable parser validation by passing "true" when creating a SAXBuilder.
SAXBuilder builder =
new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
Next, you tell the parser (Xerces) you want to validate against a schema (or schemas), and you pass the parser information about those schema. Different parsers do this in different ways. In Xerces you do this by
Ïà¹ØÎĵµ£º
If XML data in the table is less than 32K for each record, then you can directly unload the data as char. If XML data exceeds 32K for some records, then you have to unload the common data and the XML data separately. First, create a template for unloading XML into a PDS: TEMPLATE LOBFRV DSN 'AAA. ......
SQL Server 2005ΪXMLÌṩ±¾µØÖ§³Ö;ÏÖÔÚ¿ÉÒÔÔÚOPENXML½ÚµãÖÐʹÓÃÒ»¸ö´øÓÐnodes()º¯ÊýµÄXML×Ö¶ÎÀàÐͰÑÒ»¸öXMLÎļþת»¯ÎªÒ»¸öÐм¯¡£ÈÃÎÒÃÇÀ´¿´Ò»¸öʹÓÃOPENXMLµÄ¼òµ¥Àý×Ó£¬²¢ÏÔʾÈçºÎ°ÑËüת»¯ÎªÔÚSQL Server 2005ÖÐʹÓÃXML×Ö¶ÎÀàÐͺÍnodes()º¯Êý¡£
¡¡¡¡ÎªÁËʹÎÒÃǵÄÀý×Ó¼òµ¥»¯£¬ÎÒÃǽ«¼ÙÉèÎÒÃÇÐèÒªÖ´ÐÐijÖÖ»ùÓڲɹº¶©µ¥ÁÐ±íµ ......
*
sql xml ÈëÃÅ:
--by jinjazz
--http://blog.csdn.net/jinjazz
1¡¢xml: ÄÜÈÏÊ¶ÔªËØ¡¢ÊôÐÔºÍÖµ
2¡¢xpath: ѰַÓïÑÔ£¬ÀàËÆwind ......