Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: result-document + conditional

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 3/20/2007 8:33:00 AM

Is the second element always BB, if not how are the names determined?
Are there other elements that may appear?
-- 

Joe Fawcett (MVP - XML)

http://joe.fawcett.name

"James Hurrell" <j_hurrell@y...> wrote in message 
news:qvOdne6wAKuD1m3YRVnyjgA@p......
>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. 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent