From: <dc...@us...> - 2010-08-27 02:52:26
|
Revision: 8885 http://docbook.svn.sourceforge.net/docbook/?rev=8885&view=rev Author: dcramer Date: 2010-08-27 02:52:15 +0000 (Fri, 27 Aug 2010) Log Message: ----------- Merging trunk (r 8692:8884) into webhelp branch Modified Paths: -------------- branches/webhelp/defguide/en/stylesheets/html-titlepage.xml branches/webhelp/defguide5/en/bookinfo.xml branches/webhelp/defguide5/en/makechm.bat branches/webhelp/defguide5/en/refpages/elements/table/db.cals.table.xml branches/webhelp/defguide5/en/stylesheets/html-titlepage.xml branches/webhelp/defguide5/en/stylesheets/htmlhelp.xsl branches/webhelp/docbook/relaxng/docbook/assembly/assembly.rnc branches/webhelp/docbook/relaxng/docbook/assemblydtd/assemblydtd.rnc branches/webhelp/docbook/relaxng/docbook/docbook/Makefile branches/webhelp/docbook/relaxng/docbook/spec/docbook.xml branches/webhelp/docbook/relaxng/docbook/src/assembly-core.rnc branches/webhelp/docbook/relaxng/docbook/src/hier.rnc branches/webhelp/docbook/relaxng/docbook/src/topic.rnc branches/webhelp/docbook/relaxng/tools/db4-upgrade.xsl branches/webhelp/docbook/relaxng/tools/include.xsl branches/webhelp/docbook/relaxng/tools/rng2dtd/overrides/assembly.xml branches/webhelp/docbook/relaxng/tools/rng2dtd/style/dtx2dtd.xsl branches/webhelp/gentext/Makefile branches/webhelp/gentext/locale/bs.xml branches/webhelp/gentext/locale/hr.xml branches/webhelp/gentext/locale/hu.xml branches/webhelp/gentext/locale/ja.xml branches/webhelp/gentext/locale/nl.xml branches/webhelp/gentext/locale/ru.xml branches/webhelp/releasetools/xslns.mk branches/webhelp/xsl/README.BUILD branches/webhelp/xsl/common/Makefile branches/webhelp/xsl/common/autoidx-kimber.xsl branches/webhelp/xsl/common/autoidx-kosek.xsl branches/webhelp/xsl/common/common.xsl branches/webhelp/xsl/common/entities.ent branches/webhelp/xsl/common/gentext.xsl branches/webhelp/xsl/common/l10n.dtd branches/webhelp/xsl/common/l10n.xml branches/webhelp/xsl/common/l10n.xsl branches/webhelp/xsl/common/pi.xsl branches/webhelp/xsl/common/stripns.xsl branches/webhelp/xsl/epub/bin/lib/docbook.rb branches/webhelp/xsl/epub/bin/spec/README branches/webhelp/xsl/epub/bin/spec/epub_realbook_spec.rb branches/webhelp/xsl/epub/bin/spec/epub_regressions_spec.rb branches/webhelp/xsl/epub/bin/spec/epub_spec.rb branches/webhelp/xsl/epub/bin/spec/examples/AMasqueOfDays.epub branches/webhelp/xsl/epub/bin/spec/spec_helper.rb branches/webhelp/xsl/epub/docbook.xsl branches/webhelp/xsl/fo/autoidx-kimber.xsl branches/webhelp/xsl/fo/autoidx-kosek.xsl branches/webhelp/xsl/fo/graphics.xsl branches/webhelp/xsl/fo/index.xsl branches/webhelp/xsl/fo/inline.xsl branches/webhelp/xsl/fo/lists.xsl branches/webhelp/xsl/fo/table.xsl branches/webhelp/xsl/fo/titlepage.xsl branches/webhelp/xsl/html/autoidx-kimber.xsl branches/webhelp/xsl/html/autoidx-kosek.xsl branches/webhelp/xsl/html/block.xsl branches/webhelp/xsl/html/docbook.css.xml branches/webhelp/xsl/html/docbook.xsl branches/webhelp/xsl/html/footnote.xsl branches/webhelp/xsl/html/formal.xsl branches/webhelp/xsl/html/inline.xsl branches/webhelp/xsl/html/table.xsl branches/webhelp/xsl/html/titlepage.templates.xml branches/webhelp/xsl/html/titlepage.xsl branches/webhelp/xsl/html/verbatim.xsl branches/webhelp/xsl/manpages/block.xsl branches/webhelp/xsl/manpages/docbook.xsl branches/webhelp/xsl/manpages/endnotes.xsl branches/webhelp/xsl/manpages/other.xsl branches/webhelp/xsl/params/callouts.extension.xml branches/webhelp/xsl/params/default.image.width.xml branches/webhelp/xsl/params/docbook.css.link.xml branches/webhelp/xsl/params/draft.watermark.image.xml branches/webhelp/xsl/params/equation.number.properties.xml branches/webhelp/xsl/params/tex.math.delims.xml branches/webhelp/xsl/params/tex.math.in.alt.xml branches/webhelp/xsl/webhelp/docsrc/readme.xml branches/webhelp/xsl/xhtml/Makefile branches/webhelp/xsl/xhtml/html2xhtml.xsl branches/webhelp/xsl/xhtml-1_1/Makefile branches/webhelp/xsl/xhtml-1_1/html2xhtml.xsl Added Paths: ----------- branches/webhelp/anttools/xspec/ branches/webhelp/anttools/xspec/README branches/webhelp/anttools/xspec/com/ branches/webhelp/anttools/xspec/com/jenitennison/ branches/webhelp/anttools/xspec/com/jenitennison/xslt/ branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/ branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java branches/webhelp/anttools/xspec/coverage-report.xsl branches/webhelp/anttools/xspec/format-utils.xsl branches/webhelp/anttools/xspec/format-xspec-report-folding.xsl branches/webhelp/anttools/xspec/format-xspec-report.xsl branches/webhelp/anttools/xspec/generate-common-tests.xsl branches/webhelp/anttools/xspec/generate-query-helper.xsl branches/webhelp/anttools/xspec/generate-query-tests.xsl branches/webhelp/anttools/xspec/generate-query-utils.xql branches/webhelp/anttools/xspec/generate-tests-helper.xsl branches/webhelp/anttools/xspec/generate-tests-utils.xsl branches/webhelp/anttools/xspec/generate-xspec-tests.xsl branches/webhelp/anttools/xspec/test-report.css branches/webhelp/anttools/xspec/xspec.bat branches/webhelp/anttools/xspec/xspec.rnc branches/webhelp/anttools/xspec/xspec.sh branches/webhelp/anttools/xspec/xspec.xpl branches/webhelp/defguide5/en/examples/printer/ branches/webhelp/defguide5/en/examples/printer/Makefile branches/webhelp/defguide5/en/examples/printer/assembly.xml branches/webhelp/defguide5/en/examples/printer/quick-start.html branches/webhelp/defguide5/en/examples/printer/quick-start.xml branches/webhelp/defguide5/en/examples/printer/quick-start.xpl branches/webhelp/defguide5/en/examples/printer/src/ branches/webhelp/defguide5/en/examples/printer/src/alignment.xml branches/webhelp/defguide5/en/examples/printer/src/cables.xml branches/webhelp/defguide5/en/examples/printer/src/cartridges.xml branches/webhelp/defguide5/en/examples/printer/src/copybw.xml branches/webhelp/defguide5/en/examples/printer/src/copycolor.xml branches/webhelp/defguide5/en/examples/printer/src/drivers.xml branches/webhelp/defguide5/en/examples/printer/src/paper.xml branches/webhelp/defguide5/en/examples/printer/src/paperjam.xml branches/webhelp/defguide5/en/examples/printer/src/printing.xml branches/webhelp/defguide5/en/examples/printer/src/scanning.xml branches/webhelp/defguide5/en/examples/printer/src/unpacking.xml branches/webhelp/defguide5/en/examples/printer/topic.xml branches/webhelp/defguide5/en/examples/printer/user-guide.html branches/webhelp/defguide5/en/examples/printer/user-guide.xml branches/webhelp/defguide5/en/examples/printer/user-guide.xpl branches/webhelp/docbook/relaxng/tools/all-patterns.xsl branches/webhelp/gentext/locale/ka.xml branches/webhelp/gentext/locale/nds.xml branches/webhelp/xsl/eclipse/eclipse3.xsl Removed Paths: ------------- branches/webhelp/anttools/xspec/README branches/webhelp/anttools/xspec/com/ branches/webhelp/anttools/xspec/com/jenitennison/ branches/webhelp/anttools/xspec/com/jenitennison/xslt/ branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/ branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java branches/webhelp/anttools/xspec/coverage-report.xsl branches/webhelp/anttools/xspec/format-utils.xsl branches/webhelp/anttools/xspec/format-xspec-report-folding.xsl branches/webhelp/anttools/xspec/format-xspec-report.xsl branches/webhelp/anttools/xspec/generate-common-tests.xsl branches/webhelp/anttools/xspec/generate-query-helper.xsl branches/webhelp/anttools/xspec/generate-query-tests.xsl branches/webhelp/anttools/xspec/generate-query-utils.xql branches/webhelp/anttools/xspec/generate-tests-helper.xsl branches/webhelp/anttools/xspec/generate-tests-utils.xsl branches/webhelp/anttools/xspec/generate-xspec-tests.xsl branches/webhelp/anttools/xspec/test-report.css branches/webhelp/anttools/xspec/xspec.bat branches/webhelp/anttools/xspec/xspec.rnc branches/webhelp/anttools/xspec/xspec.sh branches/webhelp/anttools/xspec/xspec.xpl branches/webhelp/defguide5/en/examples/printer/Makefile branches/webhelp/defguide5/en/examples/printer/assembly.xml branches/webhelp/defguide5/en/examples/printer/quick-start.html branches/webhelp/defguide5/en/examples/printer/quick-start.xml branches/webhelp/defguide5/en/examples/printer/quick-start.xpl branches/webhelp/defguide5/en/examples/printer/src/ branches/webhelp/defguide5/en/examples/printer/src/alignment.xml branches/webhelp/defguide5/en/examples/printer/src/cables.xml branches/webhelp/defguide5/en/examples/printer/src/cartridges.xml branches/webhelp/defguide5/en/examples/printer/src/copybw.xml branches/webhelp/defguide5/en/examples/printer/src/copycolor.xml branches/webhelp/defguide5/en/examples/printer/src/drivers.xml branches/webhelp/defguide5/en/examples/printer/src/paper.xml branches/webhelp/defguide5/en/examples/printer/src/paperjam.xml branches/webhelp/defguide5/en/examples/printer/src/printing.xml branches/webhelp/defguide5/en/examples/printer/src/scanning.xml branches/webhelp/defguide5/en/examples/printer/src/unpacking.xml branches/webhelp/defguide5/en/examples/printer/topic.xml branches/webhelp/defguide5/en/examples/printer/user-guide.html branches/webhelp/defguide5/en/examples/printer/user-guide.xml branches/webhelp/defguide5/en/examples/printer/user-guide.xpl branches/webhelp/docbook/relaxng/tools/xml2dtd.xsl Property Changed: ---------------- branches/webhelp/ branches/webhelp/defguide/zh/po/zh.po branches/webhelp/defguide/zh/source/schema/dbebnf.dtd branches/webhelp/defguide/zh/source/schema/tdg.dtd branches/webhelp/defguide/zh/stylesheets/zh/fo.xsl branches/webhelp/defguide/zh/stylesheets/zh/html.xsl branches/webhelp/defguide5/zh/po/zh.po branches/webhelp/defguide5/zh/stylesheets/zh/ branches/webhelp/docbook/relaxng/docbook/howto/de/howto.de.xml branches/webhelp/docbook/relaxng/docbook/howto/en/Makefile branches/webhelp/docbook/relaxng/docbook/howto/en/TODO branches/webhelp/docbook/relaxng/docbook/howto/en/howto.xml branches/webhelp/docbook/relaxng/docbook/howto/en/images/ Property changes on: branches/webhelp ___________________________________________________________________ Added: svn:mergeinfo + /trunk:8693-8884 Deleted: branches/webhelp/anttools/xspec/README =================================================================== --- trunk/anttools/xspec/README 2010-08-27 00:33:44 UTC (rev 8884) +++ branches/webhelp/anttools/xspec/README 2010-08-27 02:52:15 UTC (rev 8885) @@ -1,32 +0,0 @@ -XSpec version 0.2 ------------------ - -Copyright 2008, 2010 Jeni Tennison -<http://xspec.googlecode.com> - - -About: - -XSpec is a Behaviour Driven Development (BDD) framework for XML -processing, currently focusing on XSLT and XQuery. It is based on the -Spec framework of RSpec, which is a BDD framework for Ruby. - -XSpec consists of a syntax for describing the behaviour of your XSLT -or XQuery code, and some code that enables you to test your code -against those descriptions. - -The project owners are Jeni Tennison and Florent Georges. - - -Usage: - -For more information about using XSpec, visit the project wiki at -<http://code.google.com/p/xspec/w/list>. If you have any questions, -you can also join (or search the archives of) the XSpec discussion -list: <http://groups.google.com/group/xspec-users>. - - -License: - -XSpec is released under the MIT license. For a copy of this license, -see LICENSE, or go to <http://www.opensource.org/licenses/mit-license.php>. Copied: branches/webhelp/anttools/xspec/README (from rev 8884, trunk/anttools/xspec/README) =================================================================== --- branches/webhelp/anttools/xspec/README (rev 0) +++ branches/webhelp/anttools/xspec/README 2010-08-27 02:52:15 UTC (rev 8885) @@ -0,0 +1,32 @@ +XSpec version 0.2 +----------------- + +Copyright 2008, 2010 Jeni Tennison +<http://xspec.googlecode.com> + + +About: + +XSpec is a Behaviour Driven Development (BDD) framework for XML +processing, currently focusing on XSLT and XQuery. It is based on the +Spec framework of RSpec, which is a BDD framework for Ruby. + +XSpec consists of a syntax for describing the behaviour of your XSLT +or XQuery code, and some code that enables you to test your code +against those descriptions. + +The project owners are Jeni Tennison and Florent Georges. + + +Usage: + +For more information about using XSpec, visit the project wiki at +<http://code.google.com/p/xspec/w/list>. If you have any questions, +you can also join (or search the archives of) the XSpec discussion +list: <http://groups.google.com/group/xspec-users>. + + +License: + +XSpec is released under the MIT license. For a copy of this license, +see LICENSE, or go to <http://www.opensource.org/licenses/mit-license.php>. Deleted: branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class =================================================================== (Binary files differ) Copied: branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class (from rev 8884, trunk/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class) =================================================================== (Binary files differ) Deleted: branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java =================================================================== --- trunk/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java 2010-08-27 00:33:44 UTC (rev 8884) +++ branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java 2010-08-27 02:52:15 UTC (rev 8885) @@ -1,199 +0,0 @@ -/****************************************************************************/ -/* File: XSLTCoverageTraceListener.java */ -/* Author: Jeni Tennsion */ -/* URI: http://xspec.googlecode.com/ */ -/* Tags: */ -/* Copyright (c) 2008, 2010 (see end of file.) */ -/* ------------------------------------------------------------------------ */ - - -package com.jenitennison.xslt.tests; - -import net.sf.saxon.trace.TraceListener; -import net.sf.saxon.trace.InstructionInfo; -import net.sf.saxon.trace.Location; -import net.sf.saxon.expr.XPathContext; -import net.sf.saxon.om.Item; -import net.sf.saxon.om.StandardNames; -import java.lang.String; -import java.util.HashMap; -import java.util.HashSet; -import java.io.PrintStream; - -/** - * A Simple trace listener for XSLT that writes messages (by default) to System.err - */ - -public class XSLTCoverageTraceListener implements TraceListener { - - private PrintStream out = System.err; - private String xspecStylesheet = null; - private String utilsStylesheet = null; - private HashMap modules = new HashMap(); - private HashSet constructs = new HashSet(); - private int moduleCount = 0; - - /** - * Method called at the start of execution, that is, when the run-time transformation starts - */ - - public void open() { - out.println("<trace>"); - } - - /** - * Method called at the end of execution, that is, when the run-time execution ends - */ - - public void close() { - out.println("</trace>"); - } - - /** - * Method that is called when an instruction in the stylesheet gets processed. - * @param instruction gives information about the instruction being - * executed, and about the context in which it is executed. This object is mutable, - * so if information from the InstructionInfo is to be retained, it must be copied. - */ - - public void enter(InstructionInfo info, XPathContext context) { - int lineNumber = info.getLineNumber(); - String systemId = info.getSystemId(); - int constructType = info.getConstructType(); - if (utilsStylesheet == null && - systemId.indexOf("generate-tests-utils.xsl") != -1) { - utilsStylesheet = systemId; - out.println("<u u=\"" + systemId + "\" />"); - } else if (xspecStylesheet == null && - systemId.indexOf("/xspec/") != -1) { - xspecStylesheet = systemId; - out.println("<x u=\"" + systemId + "\" />"); - } - if (systemId != xspecStylesheet && systemId != utilsStylesheet) { - Integer module; - if (modules.containsKey(systemId)) { - module = (Integer)modules.get(systemId); - } else { - module = new Integer(moduleCount); - moduleCount += 1; - modules.put(systemId, module); - out.println("<m id=\"" + module + "\" u=\"" + systemId + "\" />"); - } - if (!constructs.contains(constructType)) { - String construct; - if (constructType < 1024) { - construct = StandardNames.getClarkName(constructType); - } else { - switch (constructType) { - case Location.LITERAL_RESULT_ELEMENT: - construct = "LITERAL_RESULT_ELEMENT"; - break; - case Location.LITERAL_RESULT_ATTRIBUTE: - construct = "LITERAL_RESULT_ATTRIBUTE"; - break; - case Location.EXTENSION_INSTRUCTION: - construct = "EXTENSION_INSTRUCTION"; - break; - case Location.TEMPLATE: - construct = "TEMPLATE"; - break; - case Location.FUNCTION_CALL: - construct = "FUNCTION_CALL"; - break; - case Location.BUILT_IN_TEMPLATE: - construct = "BUILT_IN_TEMPLATE"; - break; - case Location.XPATH_IN_XSLT: - construct = "XPATH_IN_XSLT"; - break; - case Location.LET_EXPRESSION: - construct = "LET_EXPRESSION"; - break; - case Location.TRACE_CALL: - construct = "TRACE_CALL"; - break; - case Location.SAXON_EVALUATE: - construct = "SAXON_EVALUATE"; - break; - case Location.FUNCTION: - construct = "FUNCTION"; - break; - case Location.XPATH_EXPRESSION: - construct = "XPATH_EXPRESSION"; - break; - default: - construct = "Other"; - } - } - constructs.add(constructType); - out.println("<c id=\"" + constructType + "\" n=\"" + construct + "\" />"); - } - out.println("<h l=\"" + lineNumber + "\" m=\"" + module + "\" c=\"" + constructType + "\" />"); - } - } - - /** - * Method that is called after processing an instruction of the stylesheet, - * that is, after any child instructions have been processed. - * @param instruction gives the same information that was supplied to the - * enter method, though it is not necessarily the same object. Note that the - * line number of the instruction is that of the start tag in the source stylesheet, - * not the line number of the end tag. - */ - - public void leave(InstructionInfo instruction) { - // Do nothing - } - - /** - * Method that is called by an instruction that changes the current item - * in the source document: that is, xsl:for-each, xsl:apply-templates, xsl:for-each-group. - * The method is called after the enter method for the relevant instruction, and is called - * once for each item processed. - * @param currentItem the new current item. Item objects are not mutable; it is safe to retain - * a reference to the Item for later use. - */ - - public void startCurrentItem(Item currentItem) { - // Do nothing - } - - /** - * Method that is called when an instruction has finished processing a new current item - * and is ready to select a new current item or revert to the previous current item. - * The method will be called before the leave() method for the instruction that made this - * item current. - * @param currentItem the item that was current, whose processing is now complete. This will represent - * the same underlying item as the corresponding startCurrentItem() call, though it will - * not necessarily be the same actual object. - */ - - public void endCurrentItem(Item currentItem) { - // Do nothing - } - -} - - -// -// The contents of this file are subject to the Mozilla Public License -// Version 1.0 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License -// at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and -// limitations under the License. -// -// The Original Code is: all this file. -// -// The Initial Developer of the Original Code is Edwin Glaser -// (ed...@pa...) -// -// Portions created by Jeni Tennison are Copyright (C) Jeni Tennison. -// All Rights Reserved. -// -// Contributor(s): Heavily modified by Michael Kay -// Methods implemented by Jeni Tennison -// Copied: branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java (from rev 8884, trunk/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java) =================================================================== --- branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java (rev 0) +++ branches/webhelp/anttools/xspec/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java 2010-08-27 02:52:15 UTC (rev 8885) @@ -0,0 +1,199 @@ +/****************************************************************************/ +/* File: XSLTCoverageTraceListener.java */ +/* Author: Jeni Tennsion */ +/* URI: http://xspec.googlecode.com/ */ +/* Tags: */ +/* Copyright (c) 2008, 2010 (see end of file.) */ +/* ------------------------------------------------------------------------ */ + + +package com.jenitennison.xslt.tests; + +import net.sf.saxon.trace.TraceListener; +import net.sf.saxon.trace.InstructionInfo; +import net.sf.saxon.trace.Location; +import net.sf.saxon.expr.XPathContext; +import net.sf.saxon.om.Item; +import net.sf.saxon.om.StandardNames; +import java.lang.String; +import java.util.HashMap; +import java.util.HashSet; +import java.io.PrintStream; + +/** + * A Simple trace listener for XSLT that writes messages (by default) to System.err + */ + +public class XSLTCoverageTraceListener implements TraceListener { + + private PrintStream out = System.err; + private String xspecStylesheet = null; + private String utilsStylesheet = null; + private HashMap modules = new HashMap(); + private HashSet constructs = new HashSet(); + private int moduleCount = 0; + + /** + * Method called at the start of execution, that is, when the run-time transformation starts + */ + + public void open() { + out.println("<trace>"); + } + + /** + * Method called at the end of execution, that is, when the run-time execution ends + */ + + public void close() { + out.println("</trace>"); + } + + /** + * Method that is called when an instruction in the stylesheet gets processed. + * @param instruction gives information about the instruction being + * executed, and about the context in which it is executed. This object is mutable, + * so if information from the InstructionInfo is to be retained, it must be copied. + */ + + public void enter(InstructionInfo info, XPathContext context) { + int lineNumber = info.getLineNumber(); + String systemId = info.getSystemId(); + int constructType = info.getConstructType(); + if (utilsStylesheet == null && + systemId.indexOf("generate-tests-utils.xsl") != -1) { + utilsStylesheet = systemId; + out.println("<u u=\"" + systemId + "\" />"); + } else if (xspecStylesheet == null && + systemId.indexOf("/xspec/") != -1) { + xspecStylesheet = systemId; + out.println("<x u=\"" + systemId + "\" />"); + } + if (systemId != xspecStylesheet && systemId != utilsStylesheet) { + Integer module; + if (modules.containsKey(systemId)) { + module = (Integer)modules.get(systemId); + } else { + module = new Integer(moduleCount); + moduleCount += 1; + modules.put(systemId, module); + out.println("<m id=\"" + module + "\" u=\"" + systemId + "\" />"); + } + if (!constructs.contains(constructType)) { + String construct; + if (constructType < 1024) { + construct = StandardNames.getClarkName(constructType); + } else { + switch (constructType) { + case Location.LITERAL_RESULT_ELEMENT: + construct = "LITERAL_RESULT_ELEMENT"; + break; + case Location.LITERAL_RESULT_ATTRIBUTE: + construct = "LITERAL_RESULT_ATTRIBUTE"; + break; + case Location.EXTENSION_INSTRUCTION: + construct = "EXTENSION_INSTRUCTION"; + break; + case Location.TEMPLATE: + construct = "TEMPLATE"; + break; + case Location.FUNCTION_CALL: + construct = "FUNCTION_CALL"; + break; + case Location.BUILT_IN_TEMPLATE: + construct = "BUILT_IN_TEMPLATE"; + break; + case Location.XPATH_IN_XSLT: + construct = "XPATH_IN_XSLT"; + break; + case Location.LET_EXPRESSION: + construct = "LET_EXPRESSION"; + break; + case Location.TRACE_CALL: + construct = "TRACE_CALL"; + break; + case Location.SAXON_EVALUATE: + construct = "SAXON_EVALUATE"; + break; + case Location.FUNCTION: + construct = "FUNCTION"; + break; + case Location.XPATH_EXPRESSION: + construct = "XPATH_EXPRESSION"; + break; + default: + construct = "Other"; + } + } + constructs.add(constructType); + out.println("<c id=\"" + constructType + "\" n=\"" + construct + "\" />"); + } + out.println("<h l=\"" + lineNumber + "\" m=\"" + module + "\" c=\"" + constructType + "\" />"); + } + } + + /** + * Method that is called after processing an instruction of the stylesheet, + * that is, after any child instructions have been processed. + * @param instruction gives the same information that was supplied to the + * enter method, though it is not necessarily the same object. Note that the + * line number of the instruction is that of the start tag in the source stylesheet, + * not the line number of the end tag. + */ + + public void leave(InstructionInfo instruction) { + // Do nothing + } + + /** + * Method that is called by an instruction that changes the current item + * in the source document: that is, xsl:for-each, xsl:apply-templates, xsl:for-each-group. + * The method is called after the enter method for the relevant instruction, and is called + * once for each item processed. + * @param currentItem the new current item. Item objects are not mutable; it is safe to retain + * a reference to the Item for later use. + */ + + public void startCurrentItem(Item currentItem) { + // Do nothing + } + + /** + * Method that is called when an instruction has finished processing a new current item + * and is ready to select a new current item or revert to the previous current item. + * The method will be called before the leave() method for the instruction that made this + * item current. + * @param currentItem the item that was current, whose processing is now complete. This will represent + * the same underlying item as the corresponding startCurrentItem() call, though it will + * not necessarily be the same actual object. + */ + + public void endCurrentItem(Item currentItem) { + // Do nothing + } + +} + + +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License +// at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and +// limitations under the License. +// +// The Original Code is: all this file. +// +// The Initial Developer of the Original Code is Edwin Glaser +// (ed...@pa...) +// +// Portions created by Jeni Tennison are Copyright (C) Jeni Tennison. +// All Rights Reserved. +// +// Contributor(s): Heavily modified by Michael Kay +// Methods implemented by Jeni Tennison +// Deleted: branches/webhelp/anttools/xspec/coverage-report.xsl =================================================================== --- trunk/anttools/xspec/coverage-report.xsl 2010-08-27 00:33:44 UTC (rev 8884) +++ branches/webhelp/anttools/xspec/coverage-report.xsl 2010-08-27 02:52:15 UTC (rev 8885) @@ -1,377 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- ===================================================================== --> -<!-- File: coverage-report.xsl --> -<!-- Author: Jeni Tennsion --> -<!-- URI: http://xspec.googlecode.com/ --> -<!-- Tags: --> -<!-- Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) --> -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - -<xsl:stylesheet version="2.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:test="http://www.jenitennison.com/xslt/unit-test" - xmlns:saxon="http://saxon.sf.net/" - xmlns="http://www.w3.org/1999/xhtml" - exclude-result-prefixes="xs saxon"> - -<xsl:import href="format-utils.xsl" /> - -<xsl:param name="tests" as="xs:string" required="yes" /> - -<xsl:variable name="tests-uri" as="xs:anyURI" - select="if (starts-with($tests, '/')) - then xs:anyURI($tests) - else xs:anyURI(concat('file:/', translate($tests, '\', '/')))" /> - -<xsl:variable name="stylesheet-uri" as="xs:anyURI" - select="if (doc($tests-uri)/*/@stylesheet) - then resolve-uri(doc($tests-uri)/*/@stylesheet, $tests-uri) - else $tests-uri" /> - -<xsl:variable name="trace" as="document-node()" select="/" /> - -<xsl:variable name="stylesheet-trees" as="document-node()+" - select="test:collect-stylesheets(doc($stylesheet-uri))" /> - -<xsl:function name="test:collect-stylesheets" as="document-node()+"> - <xsl:param name="stylesheets" as="document-node()+" /> - <xsl:variable name="imports" as="document-node()*" - select="document($stylesheets/*/(xsl:import|xsl:include)/@href)" /> - <xsl:variable name="new-stylesheets" as="document-node()*" - select="$stylesheets | $imports" /> - <xsl:choose> - <xsl:when test="$imports except $stylesheets"> - <xsl:sequence select="test:collect-stylesheets($stylesheets | $imports)" /> - </xsl:when> - <xsl:otherwise> - <xsl:sequence select="$stylesheets" /> - </xsl:otherwise> - </xsl:choose> -</xsl:function> - -<xsl:key name="modules" match="m" use="@u" /> -<xsl:key name="constructs" match="c" use="@id" /> -<xsl:key name="coverage" match="h" use="concat(@m, ':', @l)" /> - -<xsl:template match="/"> - <xsl:apply-templates select="." mode="test:coverage-report" /> -</xsl:template> - -<xsl:template match="/" mode="test:coverage-report"> - <html> - <head> - <title>Test Coverage Report for <xsl:value-of select="test:format-URI($stylesheet-uri)" /></title> - <link rel="stylesheet" type="text/css" - href="{resolve-uri('test-report.css', static-base-uri())}" /> - </head> - <body> - <h1>Test Coverage Report</h1> - <p>Stylesheet: <a href="{$stylesheet-uri}"><xsl:value-of select="test:format-URI($stylesheet-uri)" /></a></p> - <xsl:apply-templates select="$stylesheet-trees/xsl:*" mode="test:coverage-report" /> - </body> - </html> -</xsl:template> - -<xsl:template match="xsl:stylesheet | xsl:transform" mode="test:coverage-report"> - <xsl:variable name="stylesheet-uri" as="xs:anyURI" - select="base-uri(.)" /> - <xsl:variable name="stylesheet-tree" as="document-node()" - select=".." /> - <xsl:variable name="stylesheet-string" as="xs:string" - select="unparsed-text($stylesheet-uri)" /> - <xsl:variable name="stylesheet-lines" as="xs:string+" - select="tokenize($stylesheet-string, '\n')" /> - <xsl:variable name="number-of-lines" as="xs:integer" - select="count($stylesheet-lines)" /> - <xsl:variable name="number-width" as="xs:integer" - select="string-length(xs:string($number-of-lines))" /> - <xsl:variable name="number-format" as="xs:string" - select="string-join(for $i in 1 to $number-width return '0', '')" /> - <xsl:variable name="module" as="xs:string?"> - <xsl:variable name="uri" as="xs:string" - select="if (starts-with($stylesheet-uri, '/')) - then concat('file:', $stylesheet-uri) - else $stylesheet-uri" /> - <xsl:sequence select="key('modules', $uri, $trace)/@id" /> - </xsl:variable> - <h2> - module: <xsl:value-of select="$stylesheet-uri" />; - <xsl:value-of select="$number-of-lines" /> lines - </h2> - <xsl:choose> - <xsl:when test="empty($module)"> - <p><span class="missed">not used</span></p> - </xsl:when> - <xsl:otherwise> - <pre> - <xsl:value-of select="format-number(1, $number-format)" /> - <xsl:text>: </xsl:text> - <xsl:call-template name="test:output-lines"> - <xsl:with-param name="line-number" select="0" /> - <xsl:with-param name="stylesheet-string" select="$stylesheet-string" /> - <xsl:with-param name="node" select="." /> - <xsl:with-param name="number-format" tunnel="yes" select="$number-format" /> - <xsl:with-param name="module" tunnel="yes" select="$module" /> - </xsl:call-template> - </pre> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:variable name="attribute-regex" as="xs:string"> - <xsl:value-of> - \s+ - ([^>\s]+) <!-- 1: the name of the attribute --> - \s* - = - \s* - ( <!-- 2: the value of the attribute (with quotes) --> - "([^"]*)" <!-- 3: the value without quotes --> - | - '([^']*)' <!-- 4: also the value without quotes --> - ) - </xsl:value-of> -</xsl:variable> - -<xsl:variable name="construct-regex" as="xs:string"> - <xsl:value-of> - ^ - ( <!-- 1: the construct --> - ([^<]+) <!-- 2: some text --> - | - (<!-- <!-- 3: a comment --> - ([^-]|-[^-])* <!-- 4: the content of the comment --> - -->) - | - (<\? <!-- 5: a PI --> - ([^?]|\?[^>])* <!-- 6: the content of the PI --> - \?>) - | - (<\[CDATA\[ <!-- 7: a CDATA section --> - ([^\]]|\][^\]]|\]\][^>])* <!-- 8: the content of the CDATA section --> - \]\]>) - | - (</ <!-- 9: a close tag --> - ([^>]+) <!-- 10: the name of the element being closed --> - >) - | - (< <!-- 11: an open tag --> - ([^>/\s]+) <!-- 12: the name of the element being opened --> - ( <!-- 13: the attributes of the element --> - ( <!-- 14: wrapper for the attribute regex --> - <xsl:value-of select="$attribute-regex" /> <!-- 15-18 attribute stuff --> - )* - ) - \s* - (/?) <!-- 19: empty element tag flag --> - > - ) - ) - (.*) <!-- 20: the rest of the string --> - $ - </xsl:value-of> -</xsl:variable> - -<xsl:template name="test:output-lines"> - <xsl:param name="line-number" as="xs:integer" required="yes" /> - <xsl:param name="stylesheet-string" as="xs:string" required="yes" /> - <xsl:param name="node" as="node()" required="yes" /> - <xsl:param name="number-format" tunnel="yes" as="xs:string" required="yes" /> - <xsl:param name="module" tunnel="yes" as="xs:string" required="yes" /> - <xsl:analyze-string select="$stylesheet-string" - regex="{$construct-regex}" flags="sx"> - <xsl:matching-substring> - <xsl:variable name="construct" as="xs:string" select="regex-group(1)" /> - <xsl:variable name="rest" as="xs:string" select="regex-group(20)" /> - <xsl:variable name="construct-lines" as="xs:string+" - select="tokenize($construct, '\n')" /> - <xsl:variable name="endTag" as="xs:boolean" select="regex-group(9) != ''" /> - <xsl:variable name="emptyTag" as="xs:boolean" select="regex-group(19) != ''" /> - <xsl:variable name="startTag" as="xs:boolean" select="not($emptyTag) and regex-group(11) != ''" /> - <xsl:variable name="matches" as="xs:boolean" - select="($node instance of text() and - regex-group(2) != '') or - ($node instance of element() and - ($startTag or $endTag or $emptyTag) and - name($node) = (regex-group(10), regex-group(12))) or - ($node instance of comment() and - regex-group(3) != '') or - ($node instance of processing-instruction() and - regex-group(5) != '')" /> - <xsl:variable name="coverage" as="xs:string" - select="if ($matches) then test:coverage($node, $module) else 'ignored'" /> - <xsl:for-each select="$construct-lines"> - <xsl:if test="position() != 1"> - <xsl:text>
</xsl:text> - <xsl:value-of select="format-number($line-number + position(), $number-format)" /> - <xsl:text>: </xsl:text> - </xsl:if> - <span class="{$coverage}"> - <xsl:value-of select="." /> - </span> - </xsl:for-each> - <xsl:if test="$rest != ''"> - <xsl:call-template name="test:output-lines"> - <xsl:with-param name="line-number" select="$line-number + count($construct-lines) - 1" /> - <xsl:with-param name="stylesheet-string" select="$rest" /> - <xsl:with-param name="node" as="node()"> - <xsl:choose> - <xsl:when test="$matches"> - <xsl:choose> - <xsl:when test="$startTag"> - <xsl:choose> - <xsl:when test="$node/node()"> - <xsl:sequence select="$node/node()[1]" /> - </xsl:when> - <xsl:otherwise> - <xsl:sequence select="$node" /> - </xsl:otherwise> - </xsl:choose> - </xsl:when> - <xsl:otherwise> - <xsl:choose> - <xsl:when test="$node/following-sibling::node()"> - <xsl:sequence select="$node/following-sibling::node()[1]" /> - </xsl:when> - <xsl:otherwise> - <xsl:sequence select="$node/parent::node()" /> - </xsl:otherwise> - </xsl:choose> - </xsl:otherwise> - </xsl:choose> - </xsl:when> - <xsl:otherwise> - <xsl:sequence select="$node" /> - </xsl:otherwise> - </xsl:choose> - </xsl:with-param> - </xsl:call-template> - </xsl:if> - </xsl:matching-substring> - <xsl:non-matching-substring> - <xsl:message terminate="yes"> - unmatched string: <xsl:value-of select="." /> - </xsl:message> - </xsl:non-matching-substring> - </xsl:analyze-string> -</xsl:template> - -<xsl:function name="test:coverage" as="xs:string"> - <xsl:param name="node" as="node()" /> - <xsl:param name="module" as="xs:string" /> - <xsl:variable name="coverage" as="xs:string+"> - <xsl:apply-templates select="$node" mode="test:coverage"> - <xsl:with-param name="module" tunnel="yes" select="$module" /> - </xsl:apply-templates> - </xsl:variable> - <xsl:if test="count($coverage) > 1"> - <xsl:message terminate="yes"> - more than one coverage identified for: - <xsl:sequence select="$node" /> - </xsl:message> - </xsl:if> - <xsl:sequence select="$coverage[1]" /> -</xsl:function> - -<xsl:template match="text()[normalize-space(.) = '' and not(parent::xsl:text)]" mode="test:coverage">ignored</xsl:template> - -<xsl:template match="processing-instruction() | comment()" mode="test:coverage">ignored</xsl:template> - -<!-- A hit on these nodes doesn't really count; you have to hit - their contents to hit them --> -<xsl:template match="xsl:otherwise | xsl:when | xsl:matching-substring | xsl:non-matching-substring | xsl:for-each | xsl:for-each-group" mode="test:coverage"> - <xsl:param name="module" tunnel="yes" as="xs:string" required="yes" /> - <xsl:variable name="hits-on-content" as="element(h)*" - select="test:hit-on-nodes(node(), $module)" /> - <xsl:choose> - <xsl:when test="exists($hits-on-content)">hit</xsl:when> - <xsl:otherwise>missed</xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:template match="* | text()" mode="test:coverage"> - <xsl:param name="module" tunnel="yes" as="xs:string" required="yes" /> - <xsl:variable name="hit" as="element(h)*" - select="test:hit-on-nodes(., $module)" /> - <xsl:choose> - <xsl:when test="exists($hit)">hit</xsl:when> - <xsl:when test="self::text() and normalize-space(.) = '' and not(parent::xsl:text)">ignored</xsl:when> - <xsl:when test="self::xsl:variable"> - <xsl:sequence select="test:coverage(following-sibling::*[not(self::xsl:variable)][1], $module)" /> - </xsl:when> - <xsl:when test="ancestor::xsl:variable"> - <xsl:sequence select="test:coverage(ancestor::xsl:variable[1], $module)" /> - </xsl:when> - <xsl:when test="self::xsl:stylesheet or self::xsl:transform">ignored</xsl:when> - <xsl:when test="self::xsl:function or self::xsl:template">missed</xsl:when> - <!-- A node within a top-level non-XSLT element --> - <xsl:when test="empty(ancestor::xsl:*[parent::xsl:stylesheet or parent::xsl:transform])">ignored</xsl:when> - <xsl:when test="self::xsl:param"> - <xsl:sequence select="test:coverage(parent::*, $module)" /> - </xsl:when> - <xsl:otherwise>missed</xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:template match="/" mode="test:coverage">ignored</xsl:template> - -<xsl:function name="test:hit-on-nodes" as="element(h)*"> - <xsl:param name="nodes" as="node()*" /> - <xsl:param name="module" as="xs:string" /> - <xsl:for-each select="$nodes[not(self::text()[not(normalize-space())])]"> - <xsl:variable name="hits" as="element(h)*" - select="test:hit-on-lines(saxon:line-number(.), $module)" /> - <xsl:variable name="name" as="xs:string" - select="concat('{', namespace-uri(.), '}', local-name(.))" /> - <xsl:for-each select="$hits"> - <xsl:variable name="construct" as="xs:string" - select="key('constructs', @c)/@n" /> - <xsl:if test="$name = $construct or - not(starts-with($construct, '{'))"> - <xsl:sequence select="." /> - </xsl:if> - </xsl:for-each> - </xsl:for-each> -</xsl:function> - -<xsl:function name="test:hit-on-lines" as="element(h)*"> - <xsl:param name="line-numbers" as="xs:integer*" /> - <xsl:param name="module" as="xs:string" /> - <xsl:variable name="keys" as="xs:string*" - select="for $l in $line-numbers - return concat($module, ':', $l)" /> - <xsl:sequence select="key('coverage', $keys, $trace)" /> -</xsl:function> - -</xsl:stylesheet> - - -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. --> -<!-- --> -<!-- Copyright (c) 2008, 2010 Jeni Tennsion --> -<!-- --> -<!-- The contents of this file are subject to the MIT License (see the URI --> -<!-- http://www.opensource.org/licenses/mit-license.php for details). --> -<!-- --> -<!-- Permission is hereby granted, free of charge, to any person obtaining --> -<!-- a copy of this software and associated documentation files (the --> -<!-- "Software"), to deal in the Software without restriction, including --> -<!-- without limitation the rights to use, copy, modify, merge, publish, --> -<!-- distribute, sublicense, and/or sell copies of the Software, and to --> -<!-- permit persons to whom the Software is furnished to do so, subject to --> -<!-- the following conditions: --> -<!-- --> -<!-- The above copyright notice and this permission notice shall be --> -<!-- included in all copies or substantial portions of the Software. --> -<!-- --> -<!-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, --> -<!-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --> -<!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.--> -<!-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --> -<!-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --> -<!-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --> -<!-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> Copied: branches/webhelp/anttools/xspec/coverage-report.xsl (from rev 8884, trunk/anttools/xspec/coverage-report.xsl) =================================================================== --- branches/webhelp/anttools/xspec/coverage-report.xsl (rev 0) +++ branches/webhelp/anttools/xspec/coverage-report.xsl 2010-08-27 02:52:15 UTC (rev 8885) @@ -0,0 +1,377 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- ===================================================================== --> +<!-- File: coverage-report.xsl --> +<!-- Author: Jeni Tennsion --> +<!-- URI: http://xspec.googlecode.com/ --> +<!-- Tags: --> +<!-- Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) --> +<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + + +<xsl:stylesheet version="2.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:test="http://www.jenitennison.com/xslt/unit-test" + xmlns:saxon="http://saxon.sf.net/" + xmlns="http://www.w3.org/1999/xhtml" + exclude-result-prefixes="xs saxon"> + +<xsl:import href="format-utils.xsl" /> + +<xsl:param name="tests" as="xs:string" required="yes" /> + +<xsl:variable name="tests-uri" as="xs:anyURI" + select="if (starts-with($tests, '/')) + then xs:anyURI($tests) + else xs:anyURI(concat('file:/', translate($tests, '\', '/')))" /> + +<xsl:variable name="stylesheet-uri" as="xs:anyURI" + select="if (doc($tests-uri)/*/@stylesheet) + then resolve-uri(doc($tests-uri)/*/@stylesheet, $tests-uri) + else $tests-uri" /> + +<xsl:variable name="trace" as="document-node()" select="/" /> + +<xsl:variable name="stylesheet-trees" as="document-node()+" + select="test:collect-stylesheets(doc($stylesheet-uri))" /> + +<xsl:function name="test:collect-stylesheets" as="document-node()+"> + <xsl:param name="stylesheets" as="document-node()+" /> + <xsl:variable name="imports" as="document-node()*" + select="document($stylesheets/*/(xsl:import|xsl:include)/@href)" /> + <xsl:variable name="new-stylesheets" as="document-node()*" + select="$stylesheets | $imports" /> + <xsl:choose> + <xsl:when test="$imports except $stylesheets"> + <xsl:sequence select="test:collect-stylesheets($stylesheets | $imports)" /> + </xsl:when> + <xsl:otherwise> + <xsl:sequence select="$stylesheets" /> + </xsl:otherwise> + </xsl:choose> +</xsl:function> + +<xsl:key name="modules" match="m" use="@u" /> +<xsl:key name="constructs" match="c" use="@id" /> +<xsl:key name="coverage" match="h" use="concat(@m, ':', @l)" /> + +<xsl:template match="/"> + <xsl:apply-templates select="." mode="test:coverage-report" /> +</xsl:template> + +<xsl:template match="/" mode="test:coverage-report"> + <html> + <head> + <title>Test Coverage Report for <xsl:value-of select="test:format-URI($stylesheet-uri)" /></title> + <link rel="stylesheet" type="text/css" + href="{resolve-uri('test-report.css', static-base-uri())}" /> + </head> + <body> + <h1>Test Coverage Report</h1> + <p>Stylesheet: <a href="{$stylesheet-uri}"><xsl:value-of select="test:format-URI($stylesheet-uri)" /></a></p> + <xsl:apply-templates select="$stylesheet-trees/xsl:*" mode="test:coverage-report" /> + </body> + </html> +</xsl:template> + +<xsl:template match="xsl:stylesheet | xsl:transform" mode="test:coverage-report"> + <xsl:variable name="stylesheet-uri" as="xs:anyURI" + select="base-uri(.)" /> + <xsl:variable name="stylesheet-tree" as="document-node()" + select=".." /> + <xsl:variable name="stylesheet-string" as="xs:string" + select="unparsed-text($stylesheet-uri)" /> + <xsl:variable name="stylesheet-lines" as="xs:string+" + select="tokenize($stylesheet-string, '\n')" /> + <xsl:variable name="number-of-lines" as="xs:integer" + select="count($stylesheet-lines)" /> + <xsl:variable name="number-width" as="xs:integer" + select="string-length(xs:string($number-of-lines))" /> + <xsl:variable name="number-format" as="xs:string" + select="string-join(for $i in 1 to $number-width return '0', '')" /> + <xsl:variable name="module" as="xs:string?"> + <xsl:variable name="uri" as="xs:string" + select="if (starts-with($stylesheet-uri, '/')) + then concat('file:', $stylesheet-uri) + else $stylesheet-uri" /> + <xsl:sequence select="key('modules', $uri, $trace)/@id" /> + </xsl:variable> + <h2> + module: <xsl:value-of select="$stylesheet-uri" />; + <xsl:value-of select="$number-of-lines" /> lines + </h2> + <xsl:choose> + <xsl:when test="empty($module)"> + <p><span class="missed">not used</span></p> + </xsl:when> + <xsl:otherwise> + <pre> + <xsl:value-of select="format-number(1, $number-format)" /> + <xsl:text>: </xsl:text> + <xsl:call-template name="test:output-lines"> + <xsl:with-param name="line-number" select="0" /> + <xsl:with-param name="stylesheet-string" select="$stylesheet-string" /> + <xsl:with-param name="node" select="." /> + <xsl:with-param name="number-format" tunnel="yes" select="$number-format" /> + <xsl:with-param name="module" tunnel="yes" select="$module" /> + </xsl:call-template> + </pre> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:variable name="attribute-regex" as="xs:string"> + <xsl:value-of> + \s+ + ([^>\s]+) <!-- 1: the name of the attribute --> + \s* + = + \s* + ( <!-- 2: the value of the attribute (with quotes) --> + "([^"]*)" <!-- 3: the value without quotes --> + | + '([^']*)' <!-- 4: also the value without quotes --> + ) + </xsl:value-of> +</xsl:variable> + +<xsl:variable name="construct-regex" as="xs:string"> + <xsl:value-of> + ^ + ( <!-- 1: the construct --> + ([^<]+) <!-- 2: some text --> + | + (<!-- <!-- 3: a comment --> + ([^-]|-[^-])* <!-- 4: the content of the comment --> + -->) + | + (<\? <!-- 5: a PI --> + ([^?]|\?[^>])* <!-- 6: the content of the PI --> + \?>) + | + (<\[CDATA\[ <!-- 7: a CDATA section --> + ([^\]]|\][^\]]|\]\][^>])* <!-- 8: the content of the CDATA section --> + \]\]>) + | + (</ <!-- 9: a close tag --> + ([^>]+) <!-- 10: the name of the element being closed --> + >) + | + (< <!-- 11: an open tag --> + ([^>/\s]+) <!-- 12: the name of the element being opened --> + ( <!-- 13: the attributes of the element --> + ( <!-- 14: wrapper for the attribute regex --> + <xsl:value-of select="$attribute-regex" /> <!-- 15-18 attribute stuff --> + )* + ) + \s* + (/?) <!-- 19: empty element tag flag --> + > + ) + ) + (.*) <!-- 20: the rest of the string --> + $ + </xsl:value-of> +</xsl:variable> + +<xsl:template name="test:output-lines"> + <xsl:param name="line-number" as="xs:integer" required="yes" /> + <xsl:param name="stylesheet-string" as="xs:string" required="yes" /> + <xsl:param name="node" as="node()" required="yes" /> + <xsl:param name="number-format" tunnel="yes" as="xs:string" required="yes" /> + <xsl:param name="module" tunnel="yes" as="xs:string" required="yes" /> + <xsl:analyze-string select="$stylesheet-string" + regex="{$construct-regex}" flags="sx"> + <xsl:matching-substring> + <xsl:variable name="construct" as="xs:string" select="regex-group(1)" /> + <xsl:variable name="rest" as="xs:string" select="regex-group(20)" /> + <xsl:variable name="construct-lines" as="xs:string+" + select="tokenize($construct, '\n')" /> + <xsl:variable name="endTag" as="xs:boolean" select="regex-group(9) != ''" /> + <xsl:variable name="emptyTag" as="xs:boolean" select="regex-group(19) != ''" /> + <xsl:variable name="startTag" as="xs:boolean" select="not($emptyTag) and regex-group(11) != ''" /> + <xsl:variable name="matches" as="xs:boolean" + select="($node instance of text() and + regex-group(2) != '') or + ($node instance of element() and + ($startTag or $endTag or $emptyTag) and + name($node) = (regex-group(10), regex-group(12))) or + ($node instance of comment() and + regex-group(3) != '') or + ($node instance of processing-instruction() and + regex-group(5) != '')" /> + <xsl:variable name="coverage" as="xs:string" + select="if ($matches) then test:coverage($node, $module) else 'ignored'" /> + <xsl:for-each select="$construct-lines"> + <xsl:if test="position() != 1"> + <xsl:text>
</xsl:text> + <xsl:value-of select="format-number($line-number + position(), $number-format)" /> + <xsl:text>: </xsl:text> + </xsl:if> + <span class="{$coverage}"> + <xsl:value-of select="." /> + </span> + </xsl:for-each> + <xsl:if test="$rest != ''"> + <xsl:call-template name="test:output-lines"> + <xsl:with-param name="line-number" select="$line-number + count($construct-lines) - 1" /> + <xsl:with-param name="stylesheet-string" select="$rest" /> + <xsl:with-param name="node" as="node()"> + <xsl:choose> + <xsl:when test="$matches"> + <xsl:choose> + <xsl:when test="$startTag"> + <xsl:choose> + <xsl:when test="$node/node()"> + <xsl:sequence select="$node/node()[1]" /> + </xsl:when> + <xsl:otherwise> + <xsl:sequence select="$node" /> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$node/following-sibling::node()"> + <xsl:sequence select="$node/following-sibling::node()[1]" /> + </xsl:when> + <xsl:otherwise> + <xsl:sequence select="$node/parent::node()" /> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:sequence select="$node" /> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> + </xsl:if> + </xsl:matching-substring> + <xsl:non-matching-substring> + <xsl:message terminate="yes"> + unmatched string: <xsl:value-of select="." /> + </xsl:message> + </xsl:non-matching-substring> + </xsl:analyze-string> +</xsl:template> + +<xsl:function name="test:coverage" as="xs:string"> + <xsl:param name="node" as="node()" /> + <xsl:param name="module" as="xs:string" /> + <xsl:variable name="coverage" as="xs:string+"> + <xsl:apply-templates select="$node" mode="test:coverage"> + <xsl:with-param name="module" tunnel="yes" select="$module" /> + </xsl:apply-templates> + </xsl:variable> + <xsl:if test="count($coverage) > 1"> + <xsl:message terminate="yes"> + more than one coverage identified for: + <xsl:sequence select="$node" /> + </xsl:message> + </xsl:if> + <xsl:sequence select="$coverage[1]" /> +</xsl:function> + +<xsl:template match="text()[normalize-space(.) = '' and not(parent::xsl:text)]" mode="test:coverage">ignored</xsl:template> + +<xsl:template match="processing-instruction() | comment()" mode="test:coverage">ignored</xsl:template> + +<!-- A hit on these nodes doesn't really count; you have to hit + their contents to hit them --> +<xsl:template match="xsl:otherwise | xsl:when | xsl:matching-substring | xsl:non-matching-substring | xsl:for-each | xsl:for-each-group" mode="test:coverage"> + <xsl:param name="module" tunnel="yes" as="xs:string" required="yes" /> + <xsl:variable name="hits-on-content" as="element(h)*" + select="test:hit-on-nodes(node(), $module)" /> + <xsl:choose> + <xsl:when test="exists($hits-on-content)">hit</xsl:when> + <xsl:otherwise>missed</xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="* | text()" mode="test:coverage"> + <xsl:param name="module" tunnel="yes" as="xs:string" required="yes" /> + <xsl:variable name="hit" as="element(h)*" + select="test:hit-on-nodes(., $module)" /> + <xsl:choose> + <xsl:when test="exists($hit)">hit</xsl:when> + <xsl:when test="self::text() and normalize-space(.) = '' and not(parent::xsl:text)">ignored</xsl:when> + <xsl:when test="self::xsl:variable"> + <xsl:sequence select="test:coverage(following-sibling::*[not(self::xsl:variable)][1], $module)" /> + </xsl:when> + <xsl:when test="ancestor::xsl:variable"> + <xsl:sequence select="test:coverage(ancestor::xsl:variable[1], $module)" /> + </xsl:when> + <xsl:when test="self::xsl:stylesheet or self::xsl:t... [truncated message content] |