Referencing a second XML within a JAR

Discussion in 'XML' started by Daniel Frey, Feb 10, 2006.

  1. Daniel Frey

    Daniel Frey Guest

    Hi

    I am using XML to persist Java objects (with XStream). I have a general
    leak of knowledge how ENTITY references within a XML can point to
    another XML in a JAR. I.e. the following XML would reference a file
    called file1.xml in the same directory:

    <?xml version='1.0'?>
    <!DOCTYPE root [ <!ENTITY file1 SYSTEM "file1.xml"> ]>
    <root id="0">
    &file1;
    ...
    </root>

    But I do not have both files in the same directory. Instead they are
    located in different JARs. Do you know how to address an XML in a JAR?
    Can I use kind of an absolute link like

    <!DOCTYPE root [ <!ENTITY file1 SYSTEM
    "/my/package/in/a/jar/file1.xml"> ]>

    to point to the jared external XML. Any idea would be highly
    appreciated.

    Cheers
    Daniel Frey
    Daniel Frey, Feb 10, 2006
    #1
    1. Advertising

  2. Daniel Frey wrote:
    > Do you know how to address an XML in a JAR?


    XML doesn't understand the concept of jarfiles. All it works with is
    URIs. So there's no guaranteed portable solution.

    Many (not all) XML processors will let you plug in an "entity resolver"
    or "uri resolver", which is code you've written to describe where and
    how they should try to search when attempting to retrieve additional
    information. If you write one that understands which jarfiles you want
    to search, and how to do that search and pull the data out of them, that
    will do what you want.

    *SOME* processors may have this kind of capability built in -- I've seen
    a few programs that understand URIs starting with jar: as requests to
    retrieve one entry from a jarfile -- but you'd have to check the docs
    for your program.

    There may be other solutions -- but again, that's going to be a matter
    of exactly what your software supports. And if you can't make it work
    with your tools, you may have to either change tools or do something
    different.
    Joe Kesselman, Feb 10, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    568
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,719
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,754
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    659
    Arnold Peters
    Jan 5, 2005
  5. Mike Dearman
    Replies:
    1
    Views:
    190
    Mike Dearman
    Jun 23, 2004
Loading...

Share This Page