UTF-X, Unit Testing Framework - Xslt

utfx.framework
Class WrapperStylesheetGenerator

java.lang.Object
  extended by utfx.framework.WrapperStylesheetGenerator

public class WrapperStylesheetGenerator
extends java.lang.Object

Generates the wrapper XSLT stylesheets for executing the tests

Copyright © 2006 UTF-X Development Team.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

$Source: /cvs/utf-x/framework/src/java/utfx/framework/Attic/WrapperStylesheetGenerator.java,v $

Version:
$Revision: 1.1.2.4 $ $Date: 2006/08/22 14:57:09 $ $Name: release_0_0_8_alpha $
Author:
Alex Daniel

Field Summary
private  javax.xml.parsers.DocumentBuilder db
          DOM Document builder
private  javax.xml.parsers.DocumentBuilderFactory dbf
          DOM Document builder factory
private  org.apache.log4j.Logger log
          log4j logging facility
(package private)  java.lang.String stylesheetUnderTestURI
          URI of stylesheet under test
private  javax.xml.xpath.XPath xpath
          Xpath
private  javax.xml.xpath.XPathFactory xpf
          XPath factory
 
Constructor Summary
WrapperStylesheetGenerator(java.lang.String stylesheetUnderTestURI)
          Construct a new WrapperStylesheetGenerator
 
Method Summary
private  void addApplyTemplates(org.w3c.dom.Document wrapperDoc, org.w3c.dom.Element utfxWrapperElement, java.lang.String sourceContextNode)
          Adds XSLT-elements for apply-templates to wrapperDoc creates the element and appends it to utfxWrapperElement
private  void addCallTemplate(org.w3c.dom.Document wrapperDoc, org.w3c.dom.Element utfxWrapperElement, org.w3c.dom.Element elem, java.lang.String sourceContextNode)
          Adds XSLT-elements for calling a named template to wrapperDoc Following elements are added to utfxWrapperElement as childs or context-node attribute
private  void addCallTemplateParameters(org.w3c.dom.Document wrapperDoc, org.w3c.dom.Element elem, org.w3c.dom.Element xslCallTemplate)
          Adds with-param elements to wrapperDoc
private  void addStylesheetParams(org.w3c.dom.Document wrapperDoc, org.w3c.dom.Element elem)
          Adds code for stylesheet parameters to wrapperDoc
private  void copySelectAttrOrChildNodes(org.w3c.dom.Element src, org.w3c.dom.Document doc, org.w3c.dom.Element dst)
          Copies the select attribute if available or its childnodes to destination element
private  java.lang.String getSourceContextNode(org.w3c.dom.Element testElement)
          Get the content of the context-node attribute of utfx:source element Empty string is returned when attribute isn't present.
 java.lang.String getStylesheetUnderTestURI()
          Get the Uniform Resource Identifier to the stylesheet under test
 org.w3c.dom.Document getWrapper(org.w3c.dom.Element testElement)
          Constructs a wrapper document for executing a test
private  void importAndAppendChildNodes(org.w3c.dom.Element src, org.w3c.dom.Document doc, org.w3c.dom.Element dst)
          Copies childnodes to destination element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xpf

private javax.xml.xpath.XPathFactory xpf
XPath factory


xpath

private javax.xml.xpath.XPath xpath
Xpath


dbf

private javax.xml.parsers.DocumentBuilderFactory dbf
DOM Document builder factory


db

private javax.xml.parsers.DocumentBuilder db
DOM Document builder


stylesheetUnderTestURI

java.lang.String stylesheetUnderTestURI
URI of stylesheet under test


log

private org.apache.log4j.Logger log
log4j logging facility

Constructor Detail

WrapperStylesheetGenerator

public WrapperStylesheetGenerator(java.lang.String stylesheetUnderTestURI)
                           throws javax.xml.parsers.ParserConfigurationException
Construct a new WrapperStylesheetGenerator

Parameters:
stylesheetUnderTestURI - Uniform Resource Identifier to the stylesheet under test
Throws:
javax.xml.parsers.ParserConfigurationException
Method Detail

getStylesheetUnderTestURI

public java.lang.String getStylesheetUnderTestURI()
Get the Uniform Resource Identifier to the stylesheet under test

Returns:
Uniform Resource Identifier to the stylesheet under test

getWrapper

public org.w3c.dom.Document getWrapper(org.w3c.dom.Element testElement)
                                throws java.lang.Exception
Constructs a wrapper document for executing a test

Parameters:
testElement - utfx:test element
Returns:
wrapper document for executing a test
Throws:
java.lang.Exception

getSourceContextNode

private java.lang.String getSourceContextNode(org.w3c.dom.Element testElement)
                                       throws java.lang.Exception
Get the content of the context-node attribute of utfx:source element Empty string is returned when attribute isn't present. When the slash at the beginning of context-node is missing it is added.

Parameters:
testElement -
Returns:
content of the context-node attribute of utfx:source element
Throws:
java.lang.Exception

addStylesheetParams

private void addStylesheetParams(org.w3c.dom.Document wrapperDoc,
                                 org.w3c.dom.Element elem)
                          throws java.lang.Exception
Adds code for stylesheet parameters to wrapperDoc

Parameters:
wrapperDoc - DOM Document representing the UTF-X test definition file.
elem - stylesheet-params element
Throws:
java.lang.Exception

addApplyTemplates

private void addApplyTemplates(org.w3c.dom.Document wrapperDoc,
                               org.w3c.dom.Element utfxWrapperElement,
                               java.lang.String sourceContextNode)
Adds XSLT-elements for apply-templates to wrapperDoc creates the element and appends it to utfxWrapperElement

Parameters:
wrapperDoc - DOM Document representing the UTF-X test definition file
utfxWrapperElement - the utfx-wrapper element from wrapper.xsl

addCallTemplate

private void addCallTemplate(org.w3c.dom.Document wrapperDoc,
                             org.w3c.dom.Element utfxWrapperElement,
                             org.w3c.dom.Element elem,
                             java.lang.String sourceContextNode)
                      throws java.lang.Exception
Adds XSLT-elements for calling a named template to wrapperDoc Following elements are added to utfxWrapperElement as childs or context-node attribute

Parameters:
wrapperDoc - DOM Document representing the UTF-X test definition file
utfxWrapperElement - the utfx-wrapper element from wrapper.xsl
elem - call-template element
Throws:
java.lang.Exception

addCallTemplateParameters

private void addCallTemplateParameters(org.w3c.dom.Document wrapperDoc,
                                       org.w3c.dom.Element elem,
                                       org.w3c.dom.Element xslCallTemplate)
Adds with-param elements to wrapperDoc

Parameters:
wrapperDoc - DOM Document representing the UTF-X test definition file.
elem - stylesheet-params element
xslCallTemplate - call-template element in wrapperDoc

copySelectAttrOrChildNodes

private void copySelectAttrOrChildNodes(org.w3c.dom.Element src,
                                        org.w3c.dom.Document doc,
                                        org.w3c.dom.Element dst)
Copies the select attribute if available or its childnodes to destination element

Parameters:
src - source element
doc - destination document
dst - destination element

importAndAppendChildNodes

private void importAndAppendChildNodes(org.w3c.dom.Element src,
                                       org.w3c.dom.Document doc,
                                       org.w3c.dom.Element dst)
Copies childnodes to destination element

Parameters:
src - source element
doc - destination document
dst - destination element

UTF-X, Unit Testing Framework - Xslt