Class XsltPostProcessor
java.lang.Object
net.finmath.smartcontracts.representablestate.xml.XsltPostProcessor
Applies a caller-selected XSLT stylesheet to an already rendered XML
representation.
A stylesheet specification is either:
- an absolute URI, loaded through a caller-provided
XsltPostProcessor.ResourceLoader; or - an explicit
xpath:expression selecting exactly one text, CDATA, or XSLTstylesheet/transformelement node in the rendered XML; or - an explicit
xpath-uri:expression selecting exactly one text, CDATA, or attribute node whose value is an absolute stylesheet URI loaded through theXsltPostProcessor.ResourceLoader.
A selected text or CDATA node must contain the complete inline
stylesheet. Its value is never reinterpreted as another URI. An element
selection is copied into a standalone document before compilation, including
namespace declarations inherited from its ancestors. URI indirection is
therefore always explicit through xpath-uri:.
Both the rendered XML and inline/external stylesheets are parsed with
DTDs and external entities disabled. XSLT imports, includes, and runtime URI
access such as document() are rejected. Stylesheet and output sizes
are bounded.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSignals an invalid specification, selected stylesheet, source XML, or transformation.static interfaceLoads the bytes of an explicitly selected external stylesheet.static classChecked failure raised by a caller-supplied external resource loader.static final recordTransformed content and its response media type. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringResponse media type for the XML output method.static final intDefault maximum transformed output size: 10 MiB characters.static final intDefault maximum stylesheet size: 1 MiB.static final StringResponse media type for the HTML output method.static final StringResponse media type for the text output method.static final StringXSLT namespace used by bothxsl:stylesheetandxsl:transform. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a post-processor with the default 1 MiB stylesheet and 10 MiB output limits.XsltPostProcessor(int maxStylesheetBytes, int maxOutputCharacters) Creates a post-processor with explicit resource limits. -
Method Summary
Modifier and TypeMethodDescriptiontransform(String renderedXml, String specification, XsltPostProcessor.ResourceLoader resourceLoader) Applies a selected stylesheet to rendered XML.
-
Field Details
-
DEFAULT_MAX_STYLESHEET_BYTES
public static final int DEFAULT_MAX_STYLESHEET_BYTESDefault maximum stylesheet size: 1 MiB.- See Also:
-
DEFAULT_MAX_OUTPUT_CHARACTERS
public static final int DEFAULT_MAX_OUTPUT_CHARACTERSDefault maximum transformed output size: 10 MiB characters.- See Also:
-
XSLT_NAMESPACE
XSLT namespace used by bothxsl:stylesheetandxsl:transform.- See Also:
-
APPLICATION_XML
Response media type for the XML output method.- See Also:
-
TEXT_HTML
Response media type for the HTML output method.- See Also:
-
TEXT_PLAIN
Response media type for the text output method.- See Also:
-
-
Constructor Details
-
XsltPostProcessor
public XsltPostProcessor()Creates a post-processor with the default 1 MiB stylesheet and 10 MiB output limits. -
XsltPostProcessor
public XsltPostProcessor(int maxStylesheetBytes, int maxOutputCharacters) Creates a post-processor with explicit resource limits.- Parameters:
maxStylesheetBytes- Maximum serialized/loaded stylesheet size in bytes.maxOutputCharacters- Maximum transformed output size in Java characters.
-
-
Method Details
-
transform
public XsltPostProcessor.TransformationResult transform(String renderedXml, String specification, XsltPostProcessor.ResourceLoader resourceLoader) throws XsltPostProcessor.ResourceLoadingException Applies a selected stylesheet to rendered XML.- Parameters:
renderedXml- Fully rendered source XML.specification- Absolute stylesheet URI, explicit inlinexpath:expression, or explicitxpath-uri:indirection expression.resourceLoader- Loader used for an absolute URI specification.- Returns:
- Transformed content and output media type.
- Throws:
XsltPostProcessor.ResourceLoadingException- If an explicitly selected external stylesheet cannot be loaded.XsltPostProcessor.InvalidXsltSpecificationException- If the source XML, specification, selected stylesheet, or transformation is invalid.
-