Also, since you are using the Java version of the parser, you need to post your messages to the xercesj dev list.
Regards,
Khaled Noaman
XML Parsers, IBM Toronto Lab
[EMAIL PROTECTED]
Alain De wrote:
Hi there,I am pretty new in the XML universe and this is
probably an old one ...Using Xerces 1.2.3, I would like to use a validating
DOM Parser to
(in)validate
a sample pizza.xml file. The problem is that the
parser doesn't
complain about the
fact that the xml is not DTD compliant. Hereafter the
Java file and the
xml file.
I would expect the parser to tell me that there is a
problem in the
attribute
extracheese of the xml file.Thanks in advance for any hint.
Alain
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pizza
[
<!ELEMENT pizza (topping,price,size)>
<!ELEMENT topping (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ATTLIST topping extracheese (yes|no) "no">
]><pizza>
<topping extracheese="yesa"> Pepperoni </topping>
<price> 10 </price>
<size> large </size>
</pizza>...
public ParseTest() {
try {domParser.setFeature("http://xml.org/sax/features/validation",
true);
} catch (Exception e) {
e.printStackTrace();
}
InputSource source = null;
source = new InputSource("/pizza.xml");
try {
domParser.parse(source);
} catch (Exception e) {
e.printStackTrace();
}
domParser.setErrorHandler(this);Document document=domParser.getDocument();
Element
element=(Element)document.getElementsByTagName("price").item(0);
String price=element.getFirstChild().getNodeValue();
System.out.println(price);
}
/**
* Insert the method's description here.
* Creation date: (1/11/01 9:35:53 PM)
*/
public void error(SAXParseException ex) {
System.out.println("[Error] "+
//getLocationString(ex)+": "+
ex.getMessage());
}
/**
* Insert the method's description here.
* Creation date: (1/11/01 9:35:53 PM)
*/
public void fatalError(SAXParseException ex) throws
SAXException {
System.out.println("[Fatal Error] "+
//getLocationString(ex)+": "+
ex.getMessage());
throw ex;
}
/**
* Insert the method's description here.
* Creation date: (1/11/01 9:15:41 PM)
* @param args java.lang.String[]
*/
public static void main(String[] args) {
ParseTest test=new ParseTest();
}
/**
* Insert the method's description here.
* Creation date: (1/11/01 9:35:53 PM)
*/
public void warning(SAXParseException ex) {
System.out.println("[Warning] "+
//getLocationString(ex)+": "+
ex.getMessage());
}
}__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]