[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: [xslt-conformance] Rendition instance
HI All: Attached please find two files: 1)) createxmlRenditionInstance.xsl - Reads the Catalogue file, the reviewed test file, and the discretionary items file and based on the readed information it filters out non-applicable test. The following steps explains the process. a) All comments are copied intact to the rendition instance. b) for each test-case element in the combined catalogue: 1) If this test just an example, if so it is discarded. 2) Was this test reviewed and got a status of "S1", if so the continue processing, if not then discard it. 3) Does this test contains a gray area? then discard it, otherwise continue processing. 4) Do this test contains a Discretionary item, if so check for name and behavior validity. If all checks then use it. If the name matches, but the behavior does not, then used the test with a behavior of "raise-error". 4) Otherwise this just a valid test, use it. 2) createhtmlRenditionInstance.xsl - uses the output of the previous stylesheet and the documentation file to create the HTML rendition instance. Please comment. Thanks, Carmelo Montanez
<?xsl version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name = "xsltdmt">XSLT-Data-Manipulation</xsl:variable> <xsl:variable name = "xsltdmot">XSLT-Data-Model</xsl:variable> <xsl:variable name = "xslttt">XSLT-Template</xsl:variable> <xsl:variable name = "xsltst">XSLT-Structure</xsl:variable> <xsl:variable name = "xsltrtt">XSLT-Result-Tree</xsl:variable> <xsl:variable name = "xsltot">XSLT-Output</xsl:variable> <xsl:variable name = "xsltext">XSLT-Extendability</xsl:variable> <xsl:variable name = "xpathcft">XPath-Core-Function</xsl:variable> <xsl:variable name = "xpathdmot">XPath-Data-Model</xsl:variable> <xsl:variable name = "xpathexpt">XPath-Expression</xsl:variable> <xsl:variable name = "xpathlpt">XPath-Location-Path</xsl:variable> <xsl:variable name = "mixed">Mixed</xsl:variable> <xsl:variable name = "documentation">documentation.xml</xsl:variable> <xsl:variable name = "xslt">http://www.w3.org/TR/xslt</xsl:variable> <xsl:variable name = "xpath">http://www.w3.org/TR/xpath</xsl:variable> <xsl:variable name = "errata">http://www.w3.org/1999/11/REC-xslt-19991116-errata</xsl:variable> <xsl:template match="/"> <xsl:apply-templates select = "test-suite"/> </xsl:template> <xsl:template match="test-suite"> <html> <head> <style> BODY { font-family: Lucida, Helvetica, Univers, sans-serif; } H1, H2, H3 { text-align: left; color: #0066CC; } H4 { color: #0066CC; } </style> </head> <body bgcolor="#ffffff"> <xsl:apply-templates select = "document($documentation)//heading[@id='topHeading']"/> <xsl:apply-templates select = "document($documentation)//heading[@id='toc']"/> <xsl:apply-templates select = "document($documentation)//heading[@id='introd']"/> <xsl:apply-templates select = "document($documentation)//heading[@id='categories']"/> <xsl:apply-templates select = "document($documentation)//heading[@id='allowable']"/> <xsl:apply-templates select = "document($documentation)//heading[@id='descrip']"/> <xsl:apply-templates select = "document($documentation)//heading[@id='xsltdmt']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xsltdmt"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xsltdmot']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xsltdmot"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xsltext']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xsltext"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xsltot']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xsltot"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xsltrtt']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xsltrtt"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xsltst']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xsltst"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xslttt']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xslttt"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xpathlpt']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xpathlpt"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xpathexpt']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xpathexpt"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xpathcft']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xpathcft"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='xpathdmot']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$xpathdmot"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='mixed']"/> <xsl:call-template name = "test-case"> <xsl:with-param name = "category" select = "$mixed"/> </xsl:call-template> <xsl:apply-templates select = "document($documentation)//heading[@id='contrib']"/> </body> </html> </xsl:template> <xsl:template name = "lessThan"> <xsl:text disable-output-escaping = "yes"><</xsl:text> </xsl:template> <xsl:template name = "greaterThan"> <xsl:text disable-output-escaping = "yes">></xsl:text> </xsl:template> <xsl:template name = "slash"> <xsl:text>/</xsl:text> </xsl:template> <xsl:template name = "buildHeading"> <xsl:param name = "id"/> <xsl:param name = "value"/> <xsl:param name = "level"/> <a name = "{$id}"> <xsl:call-template name = "lessThan"/> <xsl:value-of select = "$level"/> <xsl:call-template name = "greaterThan"/> <xsl:value-of select = "$value"/> <xsl:call-template name = "lessThan"/> <xsl:call-template name = "slash"/> <xsl:value-of select = "$level"/> <xsl:call-template name = "greaterThan"/> </a> </xsl:template> <xsl:template name = "buildTOC"> <ol> <xsl:for-each select = "item"> <li><a href = "#{@id}"><xsl:value-of select = "@value"/></a></li> <xsl:if test = "sub-item"> <ol> <xsl:for-each select = "sub-item"> <li><a href = "#{@id}"><xsl:value-of select = "@value"/></a></li> </xsl:for-each> </ol> </xsl:if> </xsl:for-each> </ol> </xsl:template> <xsl:template match = "//heading[contains(@id,'xslt') or contains(@id,'xpath') or contains(@id,'mixed')]"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@id"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> <xsl:if test = "content"> <p><xsl:value-of select = "content"/></p> </xsl:if> </xsl:template> <xsl:template match = "//heading[@id='toc']"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@lid"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> <xsl:if test = "content"> <p><xsl:value-of select = "content"/></p> </xsl:if> <xsl:call-template name = "buildTOC"/> </xsl:template> <xsl:template match = "//heading[@id='topHeading']"> <xsl:copy-of select = "."/> </xsl:template> <xsl:template match = "//heading[@id='introd']"> <a name = "{@id}"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@id"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> </a> <xsl:if test = "content"> <p> <xsl:copy-of select = "."/> </p> </xsl:if> </xsl:template> <xsl:template match = "//heading[@id='categories']"> <a name = "{@id}"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@lid"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> </a> <xsl:if test = "content"> <p><xsl:value-of select = "content"/></p> </xsl:if> </xsl:template> <xsl:template match = "//heading[@id='allowable']"> <center> <a name = "{@id}"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@lid"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> </a> </center> <xsl:if test = "content"> <p><xsl:value-of select = "content"/></p> </xsl:if> <xsl:if test = "table"> <center> <xsl:copy-of select = "table"/> </center> </xsl:if> </xsl:template> <xsl:template match = "//heading[@id ='contrib']"> <a name = "{@id}"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@lid"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> </a> <xsl:if test = "content"> <p><xsl:value-of select = "content"/></p> </xsl:if> <ul> <xsl:for-each select = "contributor"> <li><xsl:value-of select = "."/></li> </xsl:for-each> </ul> </xsl:template> <xsl:template match = "//heading[@id='descrip']"> <a name = "{@id}"> <xsl:call-template name = "buildHeading"> <xsl:with-param name = "id"><xsl:value-of select = "@lid"/></xsl:with-param> <xsl:with-param name = "value"><xsl:value-of select = "@value"/></xsl:with-param> <xsl:with-param name = "level"><xsl:value-of select = "@level"/></xsl:with-param> </xsl:call-template> </a> <xsl:if test = "content"> <p><xsl:value-of select = "content"/></p> </xsl:if> </xsl:template> <xsl:template name = "test-case"> <xsl:param name = "category"/> <xsl:variable name = "totalTests"><xsl:value-of select = "count(//test-case[@category = $category])"/></xsl:variable> <xsl:if test = "$totalTests = 0"> <table> <tr valign="top"> <td bgcolor='#ffffcc'> No tests are available for this category. </td> </tr> </table> </xsl:if> <xsl:if test = "$totalTests > 0"> <xsl:for-each select = "//test-case[(@category = $category) and not(contains(@id,'Xample'))]"> <table width="100%"> <tr valign="top"> <td width='40%'> <table bgcolor='#eeeeff' border='1' width='100%' height="100%"> <tr> <td width='50%'><b>Sections/Places</b></td> <td bgcolor='#ffffcc'> <xsl:for-each select = "spec-citation"> <xsl:choose> <xsl:when test = "(@spec = 'xslt') or (@spec = 'XSLT')"> <xsl:call-template name = "build-citation"> <xsl:with-param name = "specs" select = "$xslt"/> </xsl:call-template> </xsl:when> <xsl:when test = "@spec = 'XSLT-Errata'"> <xsl:call-template name = "build-citation"> <xsl:with-param name = "specs" select = "$errata"/> </xsl:call-template> </xsl:when> <xsl:when test = "@spec = 'xpath' or @spec = 'XPath'"> <xsl:call-template name = "build-citation"> <xsl:with-param name = "specs" select = "$xpath"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:for-each> </td> </tr> <tr valign="top"> <td width='50%'><b>Test ID:</b></td> <td bgcolor='#ffffcc'> <xsl:value-of select="@id"/></td> </tr> <xsl:if test="../creator"> <tr valign="top"> <td width='50%'><b>Collection:</b></td> <td bgcolor='#ffffcc'> <xsl:value-of select="../creator"/> </td> </tr> </xsl:if> </table> </td> <td bgcolor='#ccffff'> <xsl:value-of select = "purpose"/> <xsl:if test="descendant::output-file"> <p>There is an output test associated with this input file.</p> </xsl:if> </td> </tr> </table> </xsl:for-each> </xsl:if> </xsl:template> <!-- The first "when" on the following "choose" is ONLY temporary to accomodate inconsistensies with the Microsoft catalog file. --> <xsl:template name = "build-citation"> <xsl:param name = "specs"/> <xsl:choose> <xsl:when test = "((@type = 'Xpointer') or (@type = 'XPointer')) and not(contains(@place,'('))"> <xsl:choose> <xsl:when test = "@place = '7.7.1' or contains(@place,'7.7.1')"> <a href = "{$specs}#convert"><xsl:value-of select = "substring-before(@place,' ')"/></a> </xsl:when> <xsl:when test = "@place = '7.7' or contains(@place,'7.7')"> <a href = "{$specs}#number"><xsl:value-of select = "substring-before(@place,' ')"/></a> </xsl:when> <xsl:otherwise> <a href = "{$specs}{@place}"><xsl:value-of select = "substring-before(@place,' ')"/></a> </xsl:otherwise> </xsl:choose> <br/> </xsl:when> <xsl:when test = "@type = 'section'"> <xsl:choose> <xsl:when test = "@place = '7.7.1' or contains(@place,'7.7.1')"> <a href = "{$specs}#convert"><xsl:value-of select = "@place"/></a> </xsl:when> <xsl:when test = "@place = '7.7' or contains(@place,'7.7')"> <a href = "{$specs}#number"><xsl:value-of select = "@place"/></a> </xsl:when> <xsl:otherwise> <a href = "{$specs}"><xsl:value-of select = "@place"/></a> </xsl:otherwise> </xsl:choose> <br/> </xsl:when> <xsl:when test = "@type = 'anchor'"> <a href= "{$specs}#{@place}"><xsl:value-of select = "@place"/></a> <br/> </xsl:when> <xsl:when test = "(@type = 'Xpointer') or (@type = 'XPointer')"> <xsl:variable name = "value"><xsl:value-of select = "substring-after(substring-before(@place,')'),'(')"/></xsl:variable> <xsl:if test = "(count(preceding-sibling::*[contains(@place,$value)]) = 0) or ((count(following-sibling::*[contains(@place,$value)]) = 0) and (position != last()))"> <a href= "{$specs}#{$value}"><xsl:value-of select = "$value"/></a> <br/> </xsl:if> </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?> <!-- Creates a subset rendition instance from combined test catalog and rendition control instance. --> <!--$Date: 2002/05/21 03:12:48 $(UTC)--> <!-- Copyright (C) The Organization for the Advancement of Structured Information Standards [OASIS] (2001). All Rights Reserved. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name = "reviewedTestsFile">reviewedTests091102.xml</xsl:variable> <xsl:variable name = "discretionaryItemsFile">xsltdisc.xml</xsl:variable> <xsl:variable name = "s1">s1</xsl:variable> <xsl:variable name = "example">eXaMpLe</xsl:variable> <!-- Copy the only the nodes that are applicable. --> <!-- Any test with a "gray-area" element is eliminated from the --> <!-- final rendition. --> <!--xsl:template match = "comment()"> <xsl:comment> <xsl:value-of select = "."/> </xsl:comment> <xsl:text>
</xsl:text> </xsl:template--> <xsl:template match="test-suite"> <xsl:text> </xsl:text><test-suite><xsl:text>
</xsl:text> <xsl:apply-templates select = "//test-catalog"/> <xsl:text> </xsl:text></test-suite> </xsl:template> <!-- For each test in the catalog, check that such test was reviewed and a satus code of "s1" was assigned to it. In other words, it was reviewed by two members and it was accepted as a valid test. Also filter out any examples that may be in the catalogue file. --> <xsl:template match = "test-catalog"> <xsl:variable name = "contents"><xsl:value-of select = "."/></xsl:variable> <xsl:if test = "not(contains($contents,$example))"> <xsl:text> </xsl:text><test-catalog><xsl:text>
</xsl:text> <xsl:if test = "creator"> <xsl:text> </xsl:text><creator><xsl:value-of select = "creator"/></creator><xsl:text>
</xsl:text> </xsl:if> <xsl:if test = "date"> <xsl:text> </xsl:text><date><xsl:value-of select = "date"/></date><xsl:text>
</xsl:text> </xsl:if> <xsl:for-each select = "test-case"> <xsl:variable name = "testId" select = "@id"></xsl:variable> <xsl:variable name = "accepted" select = "document($reviewedTestsFile)//test[@id = $testId and @status = $s1]"></xsl:variable> <xsl:if test = "(count($accepted) > 0)"> <xsl:call-template name = "process-testcase"/> </xsl:if> </xsl:for-each> <xsl:text> </xsl:text></test-catalog><xsl:text>
</xsl:text> </xsl:if> </xsl:template> <xsl:template name = "process-testcase"> <xsl:if test = "not(gray-area)"> <xsl:choose> <xsl:when test = "discretionary/discretionary-choice"> <xsl:variable name = "disc-name" select = "discretionary/discretionary-choice/@name"/> <xsl:variable name = "disc-behavior" select = "discretionary/discretionary-choice/@behavior"/> <xsl:variable name = "disc-item-tests" select = "document($discretionaryItemsFile)//item[@id = $disc-name]"/> <xsl:variable name = "value1"><xsl:value-of select = "$disc-item-tests//choice[1]/@value"/></xsl:variable> <xsl:variable name = "value2"><xsl:value-of select = "$disc-item-tests//choice[2]/@value"/></xsl:variable> <xsl:variable name = "items-contents" select = "concat($value1,$value2)"></xsl:variable> <!-- Check for the Discretionary item existance. A value greater than 0 indicates --> <!-- that such item was defined. However that is not a suficient condition to --> <!-- include the test. It's behavior value must be correct. --> <xsl:if test = "count($disc-item-tests) > 0"> <xsl:if test = "contains($items-contents,$disc-behavior)"> <xsl:text> </xsl:text> <xsl:copy-of select = "."/> <xsl:text>
</xsl:text> </xsl:if> </xsl:if> <!-- The discretionary item was found in the discretionary items --> <!-- file, however the expected behavior does not match any of the --> <!-- expected choices. The test will be included with a behavior --> <!-- of "raise-error" --> <xsl:if test = "count($disc-item-tests) > 0"> <xsl:variable name = "discretionary">discretionary</xsl:variable> <xsl:variable name = "discretionary-choice">discretionary-choice</xsl:variable> <xsl:variable name = "test-case">test-case</xsl:variable> <xsl:variable name = "category">category</xsl:variable> <xsl:variable name = "id">id</xsl:variable> <xsl:variable name = "name">name</xsl:variable> <xsl:variable name = "behavior">behavior</xsl:variable> <xsl:variable name = "assumed-behavior">raise-error</xsl:variable> <xsl:if test = "not(contains($items-contents,$disc-behavior))"> <xsl:text> </xsl:text> <xsl:element name = "test-case"> <xsl:attribute name = "{$category}"><xsl:value-of select="@category"/></xsl:attribute> <xsl:attribute name = "{$id}"><xsl:value-of select="@id"/></xsl:attribute> <xsl:text>
</xsl:text> <xsl:for-each select = "child::*"> <xsl:choose> <xsl:when test = "name(.) = $discretionary"> <xsl:text> </xsl:text> <xsl:element name = "{$discretionary}"> <xsl:text>
</xsl:text> <xsl:text> </xsl:text> <xsl:element name = "{$discretionary-choice}"> <xsl:attribute name = "{$name}"><xsl:value-of select = "discretionary-choice/@name"/></xsl:attribute> <xsl:attribute name = "{$behavior}"><xsl:value-of select = "$assumed-behavior"/></xsl:attribute> <xsl:text>
</xsl:text> <xsl:text> </xsl:text> </xsl:element> <xsl:text>
</xsl:text> <xsl:text> </xsl:text> </xsl:element> <xsl:text>
</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> <xsl:copy-of select = "."/> <xsl:text>
</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text> </xsl:text> </xsl:element> <xsl:text>
</xsl:text> </xsl:if> </xsl:if> </xsl:when> <!-- This test does not have a "discretionary-item" element at all. --> <!-- It will be included in the final rendition. --> <xsl:otherwise> <xsl:text> </xsl:text> <xsl:copy-of select = "."/> <xsl:text>
</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> </xsl:stylesheet>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC