|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cleancode.xml.XslQualifier
public class XslQualifier
A class to safely set XSL transformer parameters.
Blithely attempting to set parameters that are not present in an XSL file
will result in a TransformerConfigurationException
,
aborting the transformation.
To be able to safely call a Transformer
's setParameter
method, the XSL file must have defined a receptacle to receive
the parameter, in the form:
<xsl:param name="parameter"/>So we need to look for name attributes of param elements. Furthermore, these elements must be immediate children of the document root; in other words, the grandparent must be a document node.
Field Summary | |
---|---|
static String |
ANY_NAMESPACE
Specifier for any namespace in methods such as getElementsByTagNameNS . |
static String |
DEFAULT_SEP
Default separator between names and values in a single string. |
static String |
PARAM_ATTR
XSL attribute name for a PARAM_ELEM
that names the parameter. |
static String |
PARAM_ELEM
XSL element name that accepts an input parameter. |
static String |
VERSION
Current version of this class. |
static String |
XSL_NAMESPACE
Standard XSL namespace at the time of writing. |
Constructor Summary | |
---|---|
XslQualifier(File file,
Transformer transformer)
Creates an XSlQualifier object for the specified
file and transformer. |
Method Summary | |
---|---|
void |
allowAnyNamespace(boolean value)
Allows you to restrict or relax the namespace in which the PARAM_ELEM element must be located. |
void |
setParameter(String name,
String value)
Safely add a parameter for the transformation. |
void |
setParameterList(String[] list)
Safely add multiple parameters for the transformation. |
void |
setParameterList(String[] list,
String regexp)
Safely add multiple parameters for the transformation, separating names and values with the separator provided. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VERSION
public static final String DEFAULT_SEP
public static final String PARAM_ELEM
public static final String PARAM_ATTR
PARAM_ELEM
that names the parameter.
public static final String ANY_NAMESPACE
getElementsByTagNameNS
.
public static final String XSL_NAMESPACE
Constructor Detail |
---|
public XslQualifier(File file, Transformer transformer)
XSlQualifier
object for the specified
file and transformer.
The XSL file is scanned and a list of parameter receptacles is
created.
file
- XSL file to operate ontransformer
- transformer to use to set parametersMethod Detail |
---|
public void allowAnyNamespace(boolean value)
PARAM_ELEM
element must be located.
With a true value, ANY_NAMESPACE
is used (the default).
With a false value, XSL_NAMESPACE
is used.
value
- boolean indicating to allow any namespace or not.public void setParameter(String name, String value)
name
- - The name of the parameter,
which may begin with a namespace URI in curly braces ({}).value
- - The value object.
This can be any valid Java object.
It is up to the processor to provide the proper object coercion
or to simply pass the object on for use in an extension.Transformer.setParameter(java.lang.String, java.lang.Object)
public void setParameterList(String[] list)
DEFAULT_SEP
.
Whitespace on either side of either one is ignored.
list
- - String array containing parameter names and values.public void setParameterList(String[] list, String regexp)
DEFAULT_SEP
.
list
- - String array containing parameter names and values.regexp
- - Regular expression used to separate names from values.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
CleanCode Java Libraries | Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 |