Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL: gathering summary data from XML -file

Status
Not open for further replies.

comma

Programmer
Feb 12, 2003
24
FI
Hi all,

I would like to ask a couple of questions about XSL transformation of XML -file. I've tried to look examples, but unfortunately not found any specifically for these issues.

1)
I have the following kind of XML -logfile (rough example):

Code:
<testlog type="Device testlog">
  <selftests name="Self tests">
    <test name="Memory test">
      <subtest name="Shared RAM">
        ... some test data here ...
        <result value="PASSED" />
      </subtest>
      <subtest name="Video memory">
        ... some test data here ...
        <result value="FAILED" />
      </subtest>
      <result value="FAILED" />
    </test>
    <test name="Led test">
      ...
      <result value="PASSED" />
    </test>
  </selftests>
</testlog>


I use XSL to transform this XML to HTML. I would like to gather summary about the tests (how many passed, failed etc.) and their sub-tests and eventually maybe show this summary on top of the file and then make hyperlink to the actual test data lower on the converted HTML.

I was wondering if it's possible to gather summary with XSL, since the templates will transform the file sequentially. Or is there a way.

2) Is it possible to somehow bind two (or) more XSL stylesheets in one XML -file and show e.g. a menu, from which the user could choose an action, e.g. one could show whole log and the other only summary?

Any tips or links would be appreciated. Thank you in advance.
 
You mean something like this?

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]

	<xsl:output method="html"/>

	<xsl:template match="/">
		<b>The following test's Failed.</b><br/>
		<xsl:apply-templates select="//result[@value = 'FAILED']"/>

		<b>The following test's Passed.</b><br/>
		<xsl:apply-templates select="//result[@value = 'PASSED']"/>	

	</xsl:template>

	<xsl:template match="//result[@value = 'FAILED']">
		
		<xsl:value-of select="../@name"/>
		<br/>
	</xsl:template>

	<xsl:template match="//result[@value = 'PASSED']">
		<xsl:value-of select="../@name"/>
		<br/>
	</xsl:template>
</xsl:stylesheet>
 
Yes, thank you, now I can proceed a bit further.

Btw, is it possible to bind multiple stylesheets to one page, so that e.g. by clicking a link, only some of the data would be shown, e.g. only summary data. And the other one would show all the data?
 
That's what databases are for :)

"Ships that pass in the night and speak each other in passing;
Only a signal shown and a distant voice in the darkness;
So on the ocean of life we pass and speak one another,
Only a look and a voice; then darkness again and a silence."
- Henry Wadsworth Longfellow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top