Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Entity and classpath

Reply
Thread Tools

Entity and classpath

 
 
cochrane68@hotmail.com
Guest
Posts: n/a
 
      11-08-2005
I'm trying to access an XML snippet based on the classpath. I know how
to use a snippet based on the absolute path of a file using:

<!DOCTYPE project [
<!ENTITY test SYSTEM "file:C:\Documents and
Settings\chris\Desktop\test2.xml">
]>

However, this is going to be used as part of a J2EE application, and I
need a way to access an XML snippet based on the classpath. So my
DOCTYPE declaration would look something like:

<!DOCTYPE project [
<!ENTITY test SYSTEM "resource:test2.xml">
]>

Is there anyway to do this directly in the XML, or does XML have no
concept of a classpath?

 
Reply With Quote
 
 
 
 
Philippe Poulard
Guest
Posts: n/a
 
      11-08-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm trying to access an XML snippet based on the classpath. I know how
> to use a snippet based on the absolute path of a file using:
>
> <!DOCTYPE project [
> <!ENTITY test SYSTEM "file:C:\Documents and
> Settings\chris\Desktop\test2.xml">
> ]>
>
> However, this is going to be used as part of a J2EE application, and I
> need a way to access an XML snippet based on the classpath. So my
> DOCTYPE declaration would look something like:
>
> <!DOCTYPE project [
> <!ENTITY test SYSTEM "resource:test2.xml">
> ]>
>
> Is there anyway to do this directly in the XML, or does XML have no
> concept of a classpath?
>


XML has no concept of classpath, but it has a concept of entity resolver

with java, you just have to provide an implementation of the interface
org.xml.sax.EntityResolver that has a single method ; if it returns
null, the parsers will try to resolve the external identifier by its
own, otherwise (the case where the system identifier starts with
"resource:") you have to supply yourself the resource

to plug this entity resolver to the XML parser, refer to
javax.xml.parsers.DocumentBuilder or to org.xml.sax.XMLReader

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      11-08-2005


(E-Mail Removed) wrote:

> However, this is going to be used as part of a J2EE application, and I
> need a way to access an XML snippet based on the classpath. So my
> DOCTYPE declaration would look something like:
>
> <!DOCTYPE project [
> <!ENTITY test SYSTEM "resource:test2.xml">
> ]>
>
> Is there anyway to do this directly in the XML, or does XML have no
> concept of a classpath?


A Java class path? No, XML is not Java specific.
If you are using Java tools/APIs then you need to build your own
implementation of the interface org.xml.sax.EntityResolver I think.
But chances are someone in a group or forum about J2EE knows more about
that and might even be able to point you to existing implementations if
that resource: URL is common use there.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
cochrane68@hotmail.com
Guest
Posts: n/a
 
      11-08-2005
That's what I thought, but hoping there was an easier way. Thanks for
the responses!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
.classpath file instead of the CLASSPATH Environment variable. dontspammenow@yahoo.com Java 2 03-02-2008 08:19 AM
problem compiling project, classpath in xml ".classpath" "<classpathentry...>" jameshanley39@yahoo.co.uk Java 2 03-02-2007 12:37 PM
while using javac -classpath some.jar some.java (Where does classpath get stored?) Gabe Java 3 08-27-2004 07:02 PM
CLASSPATH, -cp and -classpath misunderstanding? Flip Java 3 02-09-2004 10:09 PM



Advertisments