[jdom-interest] verify document with JDom?
GB/DEV - Philip Nelson
philip.nelson at omniresources.com
Fri Feb 16 15:10:16 PST 2001
neither of these docs is complete, but I would try removing the file:// part
or the url, put it in the same directory as the xml and run it like that. I
would have tried it here but you didn't send complete documents.
Really, this is not a JDOM issue btw, it is (probably) a Xerces issue for
you.
good luck.
-----Original Message-----
From: Peter Bismuti [mailto:peterb at pssg.com]
Sent: Friday, February 16, 2001 3:45 PM
To: jdom-interest at jdom.org
Subject: Re: [jdom-interest] verify document with JDom?
If I try this code without validation it works fine, if I turn on validation
then it hangs. If I give a bogus URL for the DTD then it throws an
exception. Given this I think my environment should be OK.
Any ideas on why it would just hang?
Thx
<?xml version = "1.0"?>
<!DOCTYPE creditscore-request SYSTEM "
file://home/userName/Gateway/CreditScoreRequest.dtd
<file://home/peterb/Gateway/CreditScoreRequest.dtd> ">
<!--Generated by XML Authority.-->
<creditscore-request>
<!--(agent , customer)-->
<agent>
<!--(agent-code , phone-number , email)-->
<agent-code issued-by = "ATT">12345</agent-code>
<phone-number type = "business">4258838888</phone-number>
<email>bob at bob.com</email>
</agent>
<customer type = "individual">
<!--(name , address , phone-number? , fax? , mobile? , email? ,
identifier+ , number-of-service)-->
<name first-name = "bob" middle-name = "" last-name = "Jackson"
company-name = ""/>
<address address1 = "123 redmondway" address2 = "" city = "redmond" state
= "wa" zip = "98052" country = ""/>
<phone-number type = "business">4258838888</phone-number>
<fax>4253333333</fax>
<mobile>4322223333</mobile>
<email>bob at bob.com</email>
<identifier issued-by = "" issue-date = "" expire-date = "" type =
"SSN">432119873</identifier>
<number-of-service>5</number-of-service>
</customer>
</creditscore-request>
<?xml version='1.0' encoding='UTF-8' ?>
<!--Generated by XML Authority-->
<!ELEMENT phone-number (#PCDATA)>
<!ATTLIST phone-number type CDATA #IMPLIED >
<!-- Defines an e-mail address -->
<!ELEMENT email (#PCDATA)>
<!-- root element -->
<!ELEMENT creditscore-request (agent , customer)>
<!-- agent info-->
<!ELEMENT agent (agent-code , phone-number , email)>
<!ELEMENT agent-code (#PCDATA)>
<!--define which carrier this code for -->
<!ATTLIST agent-code issued-by CDATA #IMPLIED>
<!ELEMENT customer (name , address , phone-number? , fax? , mobile? , email?
, identifier+ , number-of-service)>
<!ATTLIST customer type CDATA #IMPLIED >
<!ELEMENT name EMPTY>
<!ATTLIST name first-name CDATA #IMPLIED
middle-name CDATA #IMPLIED
last-name CDATA #IMPLIED
company-name CDATA #IMPLIED >
<!-- Defines the elements of a U.S. address -->
<!ELEMENT address EMPTY>
<!ATTLIST address address1 CDATA #REQUIRED
address2 CDATA #IMPLIED
city CDATA #REQUIRED
state CDATA #REQUIRED
zip CDATA #REQUIRED
country CDATA #REQUIRED >
<!-- Defines a fax number -->
<!ELEMENT fax (#PCDATA)>
<!-- Defines a mobile phone number -->
<!ELEMENT mobile (#PCDATA)>
<!ELEMENT identifier (#PCDATA)>
<!ATTLIST identifier issued-by CDATA #IMPLIED
issue-date CDATA #IMPLIED
expire-date CDATA #IMPLIED
type CDATA #IMPLIED >
<!ELEMENT number-of-service (#PCDATA)>
----- Original Message -----
From: GB/DEV - Philip Nelson <mailto:philip.nelson at omniresources.com>
To: 'Peoter Veliki' <mailto:peoter_veliki at hotmail.com> ;
jdom-interest at jdom.org <mailto:jdom-interest at jdom.org>
Sent: Friday, February 16, 2001 1:37 PM
Subject: RE: [jdom-interest] verify document with JDom?
actually, this code works just fine. I caught an invalid xml (do dtd) and
worked with xml with a valid dtd. It must be a setup issue. As usual,
check your classpath, file path etc. and of course the dreaded "xml parsers
in the jre/lib/ext" directory
-----Original Message-----
From: Peoter Veliki [mailto:peoter_veliki at hotmail.com]
Sent: Friday, February 16, 2001 3:22 PM
To: GB/DEV - Philip Nelson; jdom-interest at jdom.org
<mailto:jdom-interest at jdom.org>
Subject: Re: [jdom-interest] verify document with JDom?
I'm giving that a shot, the problem is that it is hanging when I try to
instantiate a SAXBuilder. Any idea why it would hang? This program below
will never exit.
import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
public class XMLVerify{
public static void main(String args[]){
String fileName = "/home/peterb/Gateway/creditscoreRequest.xml";
Document xmlDoc = buildDoc(fileName);
}
public static Document buildDoc(String fileName){
try{
// Build the document with SAX and Xerces, with validation
SAXBuilder builder = new SAXBuilder(true);
// create and return the document
return builder.build(new File(fileName));
}catch(Exception e){
e.printStackTrace();
return null;
}
}
}
----- Original Message -----
From: GB/DEV - Philip Nelson <mailto:philip.nelson at omniresources.com>
To: jdom-interest at jdom.org <mailto:jdom-interest at jdom.org>
Sent: Friday, February 16, 2001 1:11 PM
Subject: RE: [jdom-interest] verify document with JDom?
When you parse the document, you can have the parser validate against the
DTD. There is not however a method to validate a JDOM Document instance
against a DTD so just use the validate flag on your builder and you will
know you have a valid document coming in.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20010216/6f8408f2/attachment.htm
More information about the jdom-interest
mailing list