You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by "Morrison, John" <Jo...@uk.experian.com> on 2001/07/17 13:09:46 UTC

XML aggregation

Hi all,

I'm trying to aggregate two pieces of xml prior to applying a xsl
transformation to the results but all the combinations I've tried have come
to naught.  Could somebody please tell me if 1) its possible ;) and 2) how
to do it!.

<xsl:apply xsl="/WEB-INF/stylesheets/sample.xsl">
	<io:request url="one.xml"/>
	<io:request url="two.xml"/>
</xsl:apply>

I'd quite like to put the results of one.xml and two inside a seperate
element, eg

<aggregated>
	<one>
		<!-- one.xml contents -->
	</one>
	<two>
		<!-- two.xml contents -->
	</two>
</aggregated>

as I've got to mimic in JSP/tags something I'm currently doing in C2.

Many thanks for any ideas/help,

John.


=======================================================================
Information in this email and any attachments are confidential, and may
not be copied or used by anyone other than the addressee, nor disclosed
to any third party without our permission.  There is no intention to
create any legally binding contract or other commitment through the use
of this email.

Experian Limited (registration number 653331).  
Registered office: Talbot House, Talbot Street, Nottingham NG1 5HF

Re: XML aggregation

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi John

From: "Morrison, John" <Jo...@uk.experian.com>
> I'm trying to aggregate two pieces of xml prior to applying a xsl
> transformation to the results but all the combinations I've tried have
come
> to naught.  Could somebody please tell me if
> 1) its possible ;)

Yes :-)


> and 2) how
> to do it!.

There's a few different ways.

In XSLT you can use the document() function to load other documents.

http://www.zvon.org/xxl/XSLTreference/Output/function_document.html


Or, if the 2 documents are static and do not have the <?xml version="1.0"?>
declarations then you could do this

<xsl:apply xsl="/WEB-INF/stylesheets/sample.xsl">
<aggregated>
<io:request url="one.xml"/>
<io:request url="two.xml"/>
</aggregated>
</xsl:apply>

If you have the documents locally as files you could just do this

<xsl:apply xsl="/WEB-INF/stylesheets/sample.xsl">
<aggregated>
<%@include file="one.xml" %>
<%@include file="two.xml" %>
</aggregated>
</xsl:apply>


Hopefully in a few days time you'll be able to do things like the following
in XTags (when some new code developed by James Elson is incorporated):-

<!-- create the composite document -->
<xtags:parse>
<aggregated/>
</xtags:parse>

<!-- append child documents to root element -->
<xtags:forEach select="/aggregated">
    <xtags:add>
        <io:request url="one.xml"/>
    </xtags:add>

    <xtags:add>
        <io:request url="two.xml"/>
    </xtags:add>
</xtags:forEach>

<!-- now style the composite document -->
<xtags:style xsl="/WEB-INF/stylesheets/sample.xsl"/>


James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com