Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7903495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:45:55+00:00 2026-06-03T09:45:55+00:00

I made a xsl merge two xml to one, then using the output to

  • 0

I made a xsl merge two xml to one, then using the output to another xsl for a html view.

When I use xmlSpy to test it, it works very well, but when I put them under a java web application, somethings is wrong.

The xsl is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" encoding="UTF-8"  />
  <xsl:strip-space elements="*" />
  <xsl:variable name="xsdresult" select="document('xsdResult.xml')" />
  <xsl:variable name="schresult" select="document('result.xml')" />
  <xsl:template match="/">
    <xsl:result-document href="fullresult.xml" method="xml">
        <fullresult> 
           <xsl:copy-of select="$schresult/node()" />  
           <xsl:copy-of select="$xsdresult/node()" />     
        </fullresult>
    </xsl:result-document>
  </xsl:template>
</xsl:stylesheet>

And this file and xml files are all under the same directory and the output file is the same.

A jsp to apply this xslt:

        <?xml version="1.0" encoding="UTF-8" ?>
    <%@ page language="java"  contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <%@taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0" prefix="xsl"%>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

    <%@ page%>

    <title>test</title>
    </head>

    <body>
   <p>
  <xsl:apply xml="WEB-INF/classes/result/result.xml" xsl="WEB-INF/classes/result/merge.xsl" />
 <xsl:apply xml="WEB-INF/classes/result/xsdResult.xml" xsl="WEB-INF/classes/result/merge.xsl" />
 <xsl:apply xml="WEB-INF/classes/result/fullresult.xml" xsl="WEB-INF/classes/result/anotherone.xsl" />
   </p>
    </body>
    </html>

The problem is in the merge.xsl, document(‘xsdResult.xml’) and document(‘result.xml’), they are always searching under eclipse_home directory, not the tomcat webapps direcotry.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:45:56+00:00Added an answer on June 3, 2026 at 9:45 am

    What you need is the URI Resolver. Looking at what happens inside the ApplyTag I don’t see how you would be able to provide your own.

    There seems to be another Apache taglib for doing similar things – xtags. The StyleTag in there seems to do a better job compared to the ApplyTag, it is using an URI Resolver (look at line 154). However, I don’t see a clean way to pass your own without subclassing from it. You may trace the code further into the URLHelper and see if modifying the URI within the document() function to be something like /WEB-INF/... will yield better results.

    That said, however, you will very likely run into another issue with the second step of your transformation where you expect to pick up the result of the first pass from the file system. Where to will the first pass dump the fullresult.xml? does the process the application server runs on behalf of have permissions to write to the file system in there? Do you even want it to write to the file system?

    I feel like you would be much better off putting together a small utility class in plain Java that would pipe your transformations using JAXP API. You would have all the control you want over parser features including the URI resolution and you wouldn’t need to use filesystem as an intermediate store. And when you do that, you can also consider running your transformation in a single pass. You can merge your documents into a xsl:variable and then apply templates on it or just apply templates to the result of each document() function individually. Unless, of course, you need to retain the result of the XML merge as well.

    Hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML document and made an XSLT to output is as HTML
I want to transform some xml using an xsl-file and output the result somehow
I have made a small xslt file to create an html output called weather.xsl
I would like to use an xml file to create a html email. I
I have made use of xsl:when to display my details. The details which I
I have a dynamically generated XML document made with PHP DOMDocument . I use
I have a bunch of XML files which I use to generate HTML pages.
I made a page using HTML which have some .jpg files and some .swf
Made a custom obj called Item with some string fields and one float. .h
I made the ultimate laugh generator using these rules. Can you implement it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.