[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Is there a better way to produce a single html via

Subject: Re: Is there a better way to produce a single html via XSLT from multiple xml files ?
From: Kamal <kbhatt@xxxxxxxxx>
Date: Sat, 22 Mar 2008 23:33:03 +1100
Re:  Is there a better way to produce a single html via
Z W wrote:
Hi

Newbie to XSLT.

I'm using Ant's xslt task to invoke Saxon 9.
I have 2 input xml files, each in a different directory.
I have 1 xls for both.
Problem:
a) I got stuck at trying to find the minimun and maximum of each attribute.
From what I understand, you are trying to get the minimum and maximum of a result. This XPath:

<xsl:value-of select="document($previousJTL)/Results/*[@label ='Init']/@time" />

Doesn't do that.

The easiest (at least to program) way of getting the min and max would be to simply sort the values then get the min/max. This is my example. Turns out the FAQ (http://www.dpawson.co.uk/xsl/sect2/N6461.html#d10052e632) has a similar example. I simplified your case (removed the document), but this is enough to get you started.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:output method="text" />
<xsl:template match="Results">
<xsl:apply-templates select="sampleResult[@label ='Init']" mode="max">
<xsl:sort select="@time" order="descending" data-type="number" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="sampleResult" mode="max">
<xsl:if test="position() = 1">
<xsl:value-of select="@time"/>
</xsl:if>


</xsl:template>

</xsl:stylesheet>

FYI, thanks to your question I found out how twisted the interaction between position, apply-templates and sort really is. Namely, sorting occurs after the XPath has matched not before. That makes sense when you think about it, but still it is debatable whether this is for the best. It definitely makes this processing more difficult.

b) Because of (a), I thought I should make 2 separate calls to the
same xls for the 2 xml files, whose outputs are html files
But this create the problem to find a way to combine these 2 html files.

Is there a better way to do this - ie could I just use a single xsl
and produce results from 2 different xml inputs
I have also posted an earlier question about min, max problem.

Thank you very much for your help.

In one of your other posts, you mention you are using Ant.

My recommendation here (if it is still relevant) is to not try and combine two HTML outputs, but combine the inputs. You mentioned using Ant, I would have a two pass process, first pass combines the two files into one, the second parse does whatever you really want to do. I do something similar with XSDs. It shouldn't be too hard to do. As I said, don't know if you need to actually do that.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.