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
Ïà¹ØÎĵµ£º
Ò»¡¢WDDXµÄ²úÉú
WDDX£¬Ó¢ÎÄÈ«³ÆÎªWeb Distributed Data
Exchange£¬ÊÇÒ»ÖÖ»ùÓÚXMLµÄWeb·Ö²¼Ê½Êý¾Ý½»»»¼¼Êõ¡£WDDX×îÔçÊÇÃÀ¹úAllaire¹«Ë¾µÄ³ÌÐò¼¼ÊõÉè¼ÆÊ¦Simeon
SimeonovΪÁ˽â¾öColdFusionÖÐÉæ¼°µ½µÄ·Ö²¼¼ÆËãÎÊÌâ¶ø½¨Á¢µÄ¡£Ëæ×ʤ×÷µÄ¿ªÕ¹£¬WDDXÖð½¥Ñݱä³ÉΪһÖÖ¿ÉÓÃÓÚ²»Í¬µÄÓ¦Óû·¾³Öн»»»¸´ÔӵĽṹ ......
*
sql xml ÈëÃÅ:
--by jinjazz
--http://blog.csdn.net/jinjazz
1¡¢xml: ÄÜÈÏÊ¶ÔªËØ¡¢ÊôÐÔºÍÖµ
2¡¢xpath: ѰַÓïÑÔ£¬ÀàËÆwind ......
ͨ¹ýJOXÇáËÉʵÏÖJavaBeansÓëXMLµÄÏ໥ת»»
JOXʹµÃÔÚXMLÎĵµÓëJava BeansÖ®¼ä½øÐÐÊý¾Ýת»»±äµÃÈÝÒ×.Äã¿ÉÒÔÀûÓÃJOXÀ´½«¶ÔÏóÐòÁл¯µ½XML.
¿ª·¢ÓïÑÔ£º Java
²Ù×÷ϵͳ£º
Èí¼þÖ÷Ò³£º http://www.wutka.com/jox.html
ÎĵµµØÖ·£º http://www.wutka.com/joxdoc.html
ÏÂÔØµ ......
XML ×÷ΪÊý¾ÝÔ´µÄʵÀý£¨TESTED£©
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" preinitialize="preInit()" fontSize="12" height="500">
<mx:Script>
  ......
дXML£º
protected void btnSave_Click(object sender, EventArgs e)
{
//ȨÏÞÅжÏ
XmlTextWriter xmlw = new XmlTextWriter(Server.MapPath("~\\") + "FriendLink.xml", Encoding.Ge ......