Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: result-document + conditional result-document + conditionalTo: NULL Date: 3/8/2007 5:43:00 PM
I have been having some trouble getting my XSL style sheet to parse
correctly.
I have some XML outputted from an SQL-Server, that I then need to turn
into HTML files. This I have done successfully, but i am having trouble
coding the XSL with conditions.
My simple example XML is as follows:
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<AA ID="10" NAME="Ten">
<BB ID_B="20" NAME_B="Twenty">
</BB>
</AA>
</ROOT>
Currently I can output the elements in the first line into individual
html files and folders. What I now need to do is to force the output
from subsequent lines into files stored in the folders created during
the processing of the first line IF a certain criteria is met.
My XSL looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="text"/>
<xsl:output method="html" indent="yes" name="html"/>
<xsl:template match="/">
<xsl:for-each select="ROOT/AA">
<xsl:variable name="filename"
select="concat('output/',@NAME,'/index.htm')" />
<xsl:value-of select="$filename" />
<!-- Creating -->
<xsl:result-document href="{$filename}" format="html">
<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title><xsl:value-of select="@NAME"/></title>
<link rel="StyleSheet" href="../style.css" type="text/css"></link>
</head>
<body>
<h4>Criterion</h4>
<hr />
<h5>Name:</h5>
<p><xsl:value-of select="@NAME"/></p>
<h5>ID:</h5>
<p><xsl:value-of select="@ID"/></p>
<hr />
</body>
</html>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Resulting in:
output/ten/index.htm for the line <AA ID="10" NAME="Ten">
I'd then like the line <BB ID_B="20" NAME_B="Twenty"> to be outputted as
follows:
output/ten/twenty/index.htm
So IF NAME=TEN on line AA then output to output/ten/
It seems I am missing something fundamental - do I need to use an
<xsl:if> or do I filter the output of the for:each? I think templates
could come into it too...
Anyideas? Thanks.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
