Entity include with relative path in XML using JAXB

Moving this from the Java Technologies for Web Services forum to this one.
With the jwsdp jars I'm trying to use JAXB to load in several specified XML files. This works fine. The XML files are read in from a relative link "/templates/mainXML.xml" and the xml string read in and passed to the unmarshaller as a StreamSource:
BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResource(xmlPath_).openStream()));
while ( (line = reader.readLine()) != null) {
buff.append(line.trim()+"\n");
String xml = buff.toString();
u.unmarshall(new StreamSource(new StringReader(xml)))
But my XML files are becoming rather large with some repitition across the files so I'd like to use the entity incude in the header of the XML to abstract some of the XML into addMe.xml e.g:
<!DOCTYPE StrategyTemplate [
<!ENTITY IncludeTimeComponent SYSTEM "file:///templates/addMe.xml">]>
with &IncludeTimeComponent;
But it gives this error:
Caused by: java.io.FileNotFoundException: \templates\addMe.xml (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at java.net.URL.openStream(URL.java:1007)
at weblogic.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:836)
at weblogic.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:767)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1095)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1513)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:152)
at com.lb.cmte.oms.interpreter.jaxb.impl.runtime.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:140)
... 11 more
It works fine if I put the file in the working directory or supply the full path e.g.
<!DOCTYPE StrategyTemplate [
<!ENTITY IncludeTimeComponent SYSTEM "file:///C:/dev/templates/addMe.xml">]>
with &IncludeTimeComponent;
I've tried using jwsdp2.0 jars rather than 1.4 I was using previously, but with the same result.
But I don't want to do that, because I don't know where that might be. I'd like to be able to supply the xml file's path as it would be shown within a JAR as I do currently for the mainXML.xml files. Thanks in advance for any help!

Oh, I see why. When XML talks about a "relative path" that means relative to the URL the XML was loaded from. But when the parser doesn't have such a URL -- for example in cases like yours where you are parsing from a String -- then it falls back to assuming the XML was loaded from the current working directory.
This is almost never a good assumption, but what else can it do?
Looking at your code, I don't understand why you are parsing from a String anyway. All of that code that reads from an input stream, ignoring the line endings and putting back new line endings, seems pointless to me. You should just marshal directly from getClass().getResource(xmlPath_) as far as I can see. Then your relative paths would work just fine.

Similar Messages

  • Missing Includes with relative Pathes

    Hello together,
    I'm rather new to Arch and i keep running into errors while including some header files from /usr/include and i don't know how to fix that. I's not like this happens on every header file so i don't know where to search anymore.
    Here is what i mean
    fatal error: vtkImageReader2.h: No such file or directory
    #include <vtkImageReader2.h>
    ^
    compilation terminated.
    and if I search for the file i can find it
    lerentis@KL45:~$ ls -al /usr/include/vtk-5.10 | grep vtkImageReader2.h
    -rw-r--r-- 1 root root 9566 Oct 15 2012 vtkImageReader2.h
    Anyone has an idea how to fix that?
    Regards
    Lerentis

    progandy wrote:
    lerentis wrote:I'm trying to build plc from the AUR, but it happened before.
    Shouldn't the default include path be recursive everything under /usr/include/ ?
    No, it shouldn't. Many libraries rely on pkg-config to simplify the generation of the necessary compiler flags, but in this case you'll have to do it manually. Add the following to INCPATH in the makefile:
    -I/usr/include/vtk-5.10
    # e.g.
    INCPATH = -I/usr/share/qt/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtNetwork -I/usr/include/QtGui -I/usr/include -I/usr/include/vtk-5.10 -I. -I.
    If i edit the PKGBUILD and try it again i get the error
    /tmp/yaourt-tmp-lerentis/aur-pcl/./PKGBUILD: line 50: INCPATH: command not found
    is this in another package?
    here is the full file
    # Maintainer : Yuxin Wu <[email protected]>
    # Contributor: Sven-Hendrik Haase <[email protected]>
    # Contributor: hauptmech
    # Contributor: figo.zhang
    # Contributor: lubosz
    pkgname=pcl
    pkgver=1.7.1
    pkgrel=1
    pkgdesc="A comprehensive open source library for n-D Point Clouds and 3D geometry processing"
    arch=('x86_64' 'i686')
    url='http://www.pointclouds.org'
    license=('BSD')
    depends=('flann' 'vtk' 'qhull' 'qt4')
    makedepends=('cmake' 'eigen3' 'boost' 'openni2')
    optdepends=('openmpi' 'cuda' 'openni2')
    source=("https://github.com/PointCloudLibrary/pcl/archive/pcl-${pkgver}.tar.gz")
    md5sums=('ce8fa17662544eb4bb7b084191a61ad5')
    build() {
    cd $srcdir/pcl-pcl-$pkgver
    # From pcl 1.7.1-1, Use Qt4, since vtk doesn't compile under Qt5
    sed -i 's/include.*pcl_find_qt5\.cmake.*//g' CMakeLists.txt
    [[ -d build ]] && rm -r build
    mkdir -p build && cd build
    # -DBUILD_gpu_people=OFF \ Disable until CUDA npp detection is fixed in cmake
    cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_CUDA=ON \
    -DBUILD_cuda_io=ON \
    -DBUILD_cuda_apps=ON \
    -DBUILD_GPU=ON \
    -DBUILD_gpu_surface=ON \
    -DBUILD_gpu_tracking=ON \
    -DBUILD_apps=ON \
    -DBUILD_app_3d_rec_framework=ON \
    -DBUILD_app_cloud_composer=ON \
    -DBUILD_app_in_hand_scanner=ON \
    -DBUILD_app_modeler=ON \
    -DBUILD_app_point_cloud_editor=ON \
    -DBUILD_examples=OFF \
    -DBUILD_global_tests=OFF \
    -DBUILD_simulation=ON \
    -DBUILD_surface_on_nurbs=ON
    INCPATH = -I/usr/include/vtk-5.10
    make
    package() {
    cd $srcdir/pcl-pcl-$pkgver/build
    make DESTDIR=$pkgdir install
    install -Dm644 ../LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    Last edited by lerentis (2014-03-25 13:24:20)

  • Error message: "conflicts with a path already in use"

    I am trying to establish through Contribute version 2's
    Connection Wizard a new connection to www.charlesfigley.com. After
    I enter this web address and hit "next >" I receive the
    following:
    Network paths can’t overlap
    The network path you have entered conflicts with a path
    already in use by one of your website connections. If you need to
    access this site at a higher level, edit the path of your existing
    connection.
    You cannot create a connection to a subfolder using this
    network path.
    I have checked with GoDaddy and they can find nothing on
    their end to account for such a conflict. Can you help solve this
    mystery? Thanks to anyone who reads this.
    Thanks,
    Charles

    I do not know Contribute 2, but what I do know that in later
    versions of the program, this message means that you have another
    connection in Contribute pointing to the same webaddress.
    Check this by doing the following:
    1. in the main menu go to Edit>My Connections
    2. check all connections there to find the path you described
    3. delete or adjust this connection

  • Acrobat X (10.0.2) trows Error when SaveAs with relative paths

    Hi,
    I'm wondering if this is a bug in Acrobat X.
    When I try to execute the script
    this.saveAs("../TEST.pdf"); or this.saveAs({cPath: "../TEST.pdf"}); it always throws this exception.
    UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
    I did a cross-check with Acrobat 9, there both scripts are working fine and my file is saved into the parent directory.
    What's going on here?

    That's courious,
    a moment ago it doens't work.
    I thought, it may be because of an restriction to the system drive (C:\).
    So I tried it on another drive, but the same result, again, again, again...
    Now, after I killed the whole Acrobat processes it works on every drive, from the console and through a folder level script for local drives and also network paths.
    On another computer I got the exception again.
    But then, after I executed the saveAs once with an absolute path it also works with relative paths.
    What the hell?

  • Parsing ejb-jar.xml using jaxb

    hi all,
    how to parse the ejb-jar.xml using jaxb? can anybody send the information about the API which we have to use to parse the ejb-jar.xml? (ejb2.0)
    i need the details about all ejbs in an application, (like jndi name, Home and Remote name). so, how can i parse the ejb descriptors?
    regards,
    panneer

    Hi Panneer,
    Well, parsing the EJB descriptors is, in principle, a task for the EJB container where they are deployed. From what you wrote I assume that you need to gather that kind of info to visualize in some (monitoring?) tool. Is that correct?
    If so, the question would be whether you have access to the EJB jar on the file system (before it's deployed) or you can only connect to the server with the already deployed EJBs. In the latter case, this information is shown in the [NWA plugins|http://help.sap.com/saphelp_nwce10/helpdata/en/0b/5b5a42ea221153e10000000a155106/frameset.htm]. There are also some [telnet commands|http://help.sap.com/saphelp_nw04/helpdata/en/79/3cf82ade038d45a21fbfdaee349b22/frameset.htm] in NW 04 and 7.0 (04s).
    If you have access to the EJB jar file, you can parse the descriptors using DOM or SAX, but I'm not aware of any pre-defined JAXB API for this purpose. Probably you can also generate the mapped classes yourself and use them, however I'm not sure how that works with DTD (because of EJB 2.0).
    HTH!
    \-- Vladimir

  • Error when reading data from XML using JAXB?

    Hi all,
    I get the error message when reading data from XML using JAXB.
    [org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.]
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException
    (AbstractUnmarshallerImpl.java:315)
         at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:481)
         at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:199)
         at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142)
    I don't find the reason, please help!
    Thanks in advance!

    The problem is sovled.

  • Problem with include and relative path in jsp

    Precompile jsp with wlappc in 9.2, I got the error "The include file was not found" when the jsp use <%@ include file="../includes/dataEntry/code_error.html" %>
              This code used to work with 8.1. I notice that someone has report the same problem with 9.0 and you have patch for it. Is it fix in 9.2 or do I require a patch as well?
              Thanks,
              Khuemy

    When you precompile, can you say "Keepgenerated=TRUE". It might help you track
              down the difference with the URL. You should only get a 404 error when the
              resource is not found at runtime, which is independant of when you compile. The
              difference should be in how the URL is compiled.
              Chris
              ali wrote:
              > I am using WLS 6.0 SP1, when I use relative path in <jsp:forward> in my JSPs
              > it forwards ok if I am using directly JSPs but if I am using pre-compiled
              > JSPs (and have proper servlet-mappings
              > in my web.xml), I get 404 error with the relative-path, if I change it to
              > absolute path with pre-compiled JSPs it forwards ok , then.
              > any ideas why this is so?
              > thanks,
              

  • Build page with screen definition in XML using XSLT in ADF 11.1.1.x

    Hi folks,
    I'm figuring out how best integrating Oracle Policy Automation/Webdeterminations in ADF. My idea is that in a ADF Taskflow I first call a Init-session webservice on OPA to initiate a session with facts queried from ADF Components.
    Then I would query a Determinations Server Webservice to get the next interview-screen definition. This gives me an xml with the definition of a screen to present. I could create an xslt that transform this to an HTML form. Then I would show a page with this (x)html form included in a container. The user could fill in the question-fields. Then on a command button I would read the values from the HTTP request and feed it into a webservice call to the Determinations Service.
    Is a scenario like this possible in ADF? And could you give me some hints to get me on track? Or would you suggest otherwise?
    The recommendation from OPA is to use data-adapters. But that are then java-classes based on an java-interface that are to be custom build on a datamodel. And I could imagine several security implications on that.
    Thanks in advance.
    Regards,
    Martien

    Can you use JAXB to unmarshall the XML document to a Java Class (and create a POJO data control out of the java class) and use it in the ADF pages as form or table or tree table?
    Take a look at the following sample how an XML document having a schema associated can be converted to a Java class and used in the UI:
    http://adftree.googlecode.com/svn/trunk/TreeSample.zip
    Thanks,
    Navaneeth

  • Links to PDF files with relative paths from a Captivate 4 project

    I'm creating a presentation in Captivate 4 (I'm making an exe file) with some links to PDF files; the links are buttons with the 'open URL or file' set. The presentation will be distributed in CDs and obviously the links will not work for they point to an absolute path in my PC. Is there another way to display external files? thanks

    "file:\file folder\filename" is not a relative path.  It's still an absolute path because you're specifying the path all the way from the root drive, whether you used a drive letter or not.
    A relative path shows where to find the other file in relation to the file that is calling it.
    Relative paths look like this:
    myDoc.doc (if the file is in the same directory as the file calling it)
    folderName/myDoc.doc (if the file is inside a folder in the same directory as the file calling it)
    ../myDoc.doc (if the file is located in the parent directory above the file that is calling it)
    ../../myDoc.doc (if the file is located two levels above the file that is calling it)
    etc
    Here's a tutorial that explains it better: http://www.communitymx.com/content/article.cfm?cid=230ad

  • Query with relative paths

    I have a client who is fairly au fait with Dreamweaver but has run into some difficulties so they have asked me to take over.
    The problem files' (downloaded from the net into Dreamweaver using the 'get' function), relative paths were 'out' by an extra hierarchical level and hence didn't display or work correctly locally on my laptop. I haven't yet looked into why this was the case but was able to fix it without too much hassle by using the find and replace feature.
    However I am confused as to why these html pages display correctly online as their paths have an extra ../ in them.
    One of the pages that has the extra level is this http://www.wildlifeartgallery.com/exhibitions/harry_becker2/harry_becker2_page1.html
    The hierachy of the files in the website is as below with the scripts and styles folders on the same level as the index.html page. The problematic pages are located 'exhibitions/harry_becker2/harry_becker2_page1.html' to page7 (page 10 is me testing).
    Surely the relative links to the styles folder should be ../../ as they are with all the other artists' exhibition pages rather than ../../../ ??
    I would be most grateful if someone could take a look for me and give me an expIanation as to how the CSS and scripts display and work without issue when they seem to be linked incorrectly or is it me going mad!!
    Thanking you in anticipation.
    Lisa
    FYI I use Dreamweaver CS5.5 on OSx 10.6 and my clients use Dreamweaver CS6 on Mountain Lion.

    First thing I will tell you at the outset is that before you downloaded the site from the remote server, you should have defined a site on your laptop by creating the necessary folders for the site name, css, scripts, images, downloads, etc etc.  this would have put you in a better position and you would have avoided doing find & replace work.
    Now coming to your main question, the links in a website are either document relative or site relative.  The difference is that with site relative, you need to provide the full http:// address but with document relative, DW will put the links like this:
    <link href="css/main.css" rel="stylesheet" type="text/css">
    </head>
    As your site is now working, you will be better off keeping it as it is otherwise, you can read the first part of David's tutorial that teaches how to setup the basic site.  It doesn't go into creating folders for images, css, scripts etc but you get the idea after you have worked on his tutorial.
    <http://www.adobe.com/devnet/dreamweaver/articles/first_website_pt1_cs6.html>
    Good luck.

  • Problem unmarshalling xml using JAXB

    I am using JAXB for processing xml, which comes from an external source. Most often, the xml gets changed from external source which causes the error during unmarshalling as the xsd has not changed. Is there a way to process the xml in same way even if xsd hasn't changed, like converting new xml to one as per xsd etc. Someone has mentioned using xslt, but I would like to get more ideas on any other technologies or third party tools to overcome this issue so that I do not have to reply upon changing xsd everytime. Thanks

    Most often, the xml gets changed from external source which causes the error during unmarshalling as the xsd has not changed.So, you've got garbage input. Your goal should be to stop that from happening rather than trying to make it work.
    so that I do not have to reply upon changing xsd everytimeIf you have to keep changing the schema then perhaps JAXB wasn't a suitable technology choice here. Or maybe the design wasn't done properly. Or maybe (see earlier comment) the input files aren't being produced properly. At any rate you need to fix the underlying problem before writing code.

  • Adobe form - Dynamic resizing and UI elements access with relative path

    In the form, there are 190+ fields, grouped nad divided into different sections. We have section(subform) and field(UI Element) configurations in which we need to make Form ui elements invisible based on section/Fields.
    eg. < Code Snippet>
    if(SectionsList<i> == <SectionName1>)
              Page1.Section1.Field1.presence     =  "hidden";
                    Page1.Section1.Field2.p1esence     =  "hidden";
              <.. rest of fields>
    if(SectionsList<i> == <SectionName2>)
              Page2.Section2.Field1.presence     =  "hidden";
                    Page2.Section2.Field2.p1esence     =  "hidden";
              <.. rest of fields>
    Here we are using absolute path for the the ui elements which includes page numbers.
    The requirement is whenever we make a section or a field invisible the form size should get resized.
    e.g.let us say we suppress 2 sections occupying 3 pages of total 8 pages of the form, then the rendered form should have only 5 pages
    There are two issues here:
    1) When the UI elements of section are hidden, the section is not getting shrinked or resized
    2) Let us say above issue gets resolved and section gets shrinked; how can we locate the UI element using script? Currently we have coded java script for hiding UI elements by giving absolute path of UI element i.e. for example   Page1.Section1.Field1

    Hi Ganga,
    Yes at the time of design itself I will have the fields for one entity in a subforms flowed.
    and all these subforms into a large subform flowed. if there are some special fields they will be into a different subform.
    with is you will have a freedom of manuplating any subsection and since all the subforms are flowed it will automatically wrap up.
    In your case I dont find a reason to have a every single filed in one subform and is flowed unless your form is something like a single column / pillar like Qutub minar.
    If you can send me your xdp file, i can fix the design issue and can check whats resetting your form data.
    Cheers,
    Sai

  • Problem with absolute path and context using Tomcat 4

    I added the following line to my server.xml:
    <Context path="/track" docBase="track" />Now I have used absolute paths(ex: /includes/css/style.css) throughout my code and it worked when I served my application from the ROOT context but when I moved it to the /track - the paths did not include the new root context.
    So instead of looking at http://localhost/track/includes/css/style.css it still looks at http://localhost/includes/css/style.css.
    Is there any kind of setting I am missing in the web.xml or server.xml? I really would like to be able to use absolute paths relative to the context root.
    Please help! Thanks in advance.
    -Chris

    Hi,
    I am not sure what exactly you are asking but here is my shot. If one tomcat is serving more than one application then the only way for tomcat to know which application to refer is by looking at the context path. Since you have the context path of /track then it should appear in all of your urls being directed to the server (for both servlet and jsp). Since you have used absolute path in all the cases either you will have to change the absolute path or you will have to define them relative (which is a better idea) to a base dir. Hope it helps.
    I added the following line to my server.xml:
    <Context path="/track" docBase="track"
    />Now I have used absolute paths(ex:
    /includes/css/style.css) throughout my code and it
    worked when I served my application from the ROOT
    context but when I moved it to the /track - the paths
    did not include the new root context.
    So instead of looking at
    http://localhost/track/includes/css/style.css it still
    looks at http://localhost/includes/css/style.css.
    Is there any kind of setting I am missing in the
    web.xml or server.xml? I really would like to be able
    to use absolute paths relative to the context root.
    Please help! Thanks in advance.
    -Chris

  • Search and replace with relative paths

    On my 4GB site, each page has a relative link to a single
    image in a top folder. I want to get rid of all the images. How do
    I search for <img src="Access/images/woCmt.gif"> and an img
    with any number of relative links such as <img
    src="../Access/images/woCmt.gif"> or <img
    src="../../Access/images/woCmt.gif"> or more ../s in the src
    path. I want a single find to replace each img tag (to that image)
    with nothing, that is delete each one. I've looked at using regular
    expression with * with no success.

    Have you tried: [\.\/]*
    That will match zero or more . or / characters (which are
    special
    Regular Expression characters, so they need to be escaped).
    HTH,
    Randy
    > On my 4GB site, each page has a relative link to a
    single image in a top
    > folder. I want to get rid of all the images. How do I
    search for <img
    > src="Access/images/woCmt.gif"> and an img with any
    number of relative links
    > such as <img src="../Access/images/woCmt.gif"> or
    <img
    > src="../../Access/images/woCmt.gif"> or more ../s in
    the src path. I want a
    > single find to replace each img tag (to that image) with
    nothing, that is
    > delete each one. I've looked at using regular expression
    with * with no success.

  • How to read file in netbeans web project with relative path.

    Hi friends,
    I have created a web project in Netbeans with following stucture.
    Exercise1
    src --> database --> ConnectionManager.java
    cofig --> databaseproperties.xml
    I want to read config\databaseproperties.xml file in src\database\ConnectionManager.java file.
    I have tried to create a file input stream with path = "config" File.separator "databaseproperties.xml".
    I am getting error of File Not Found..
    Anybody has any idea? In Netbeans what is the default context path?
    Edited by: Jaykishan on Jun 29, 2010 11:54 AM

    place the *.jrxml files in your war (e.g. WEB-INF\classes\report.jrxml) and then in your servlet:
    JasperReport report = JasperCompileManager.compileReport("report.jrxml");

Maybe you are looking for