Package org.europa.together.application
Class SaxTools
java.lang.Object
org.europa.together.application.SaxTools
- All Implemented Interfaces:
XmlTools
Implementation of XML Tools.
-
Field Summary
Fields inherited from interface org.europa.together.business.XmlTools
FEATURE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if a external schema file s configured.booleanisValid()Validate well formed XML content (XML 1.0) against a given grammar.booleanCheck XML content (XML 1.0) if is well formed. the well formed rules for XML are defined as:
- the structure of a XML document is a tree and each node is defined as TAG
- each document contains exact one root tag
- element tags are case-sensitive
- content be delimited with a beginning and end tag
- begin, end, and empty-element tags that delimit the elements are
correctly nested, with none missing and none overlapping Detail
- it contains only properly encoded legal Unicode characters
- special characters like: > < & have to be encoded
(StringUtils.escapeXmlCharacters()) Information: https://en.wikipedia.org/wiki/Well-formed_documentparseXmlFile(File xmlFile) Parse a given XML File to grab the content.parseXmlString(String xml) Parse a given XML String to grab the content.Before writeing a XML Document on a file, especially computer generated XML Content, the content should formatted by a CodeBeautifier.voidReset the external schema file to NULL.voidsetSchemaFile(File schema) Set explicit the schema file for the validation option.shrinkContent(String content) Shrink the XML content to reduce the file size for a higher performance in automated processing.transformXslt(File xml, File xslt) Transform an XML File by a given XSLT to a new Output.voidwriteXmlToFile(String content, String destinationFile) Writes a XML String into a new file.
-
Constructor Details
-
SaxTools
public SaxTools()Constructor.
-
-
Method Details
-
parseXmlFile
Description copied from interface:XmlToolsParse a given XML File to grab the content.- Specified by:
parseXmlFilein interfaceXmlTools- Parameters:
xmlFile- as File- Returns:
- content as String
-
parseXmlString
Description copied from interface:XmlToolsParse a given XML String to grab the content.- Specified by:
parseXmlStringin interfaceXmlTools- Parameters:
xml- as String- Returns:
- content as String
-
prettyPrintXml
Description copied from interface:XmlToolsBefore writeing a XML Document on a file, especially computer generated XML Content, the content should formatted by a CodeBeautifier. This function Beautifies the XML Sources with the following rules:
- set content to UTF-8 without BOM (Byte Order Mark)
- automated line breaks and indents
- remove trailing space
- replace TAB with 4 space characters- Specified by:
prettyPrintXmlin interfaceXmlTools- Returns:
- content as String
-
shrinkContent
Description copied from interface:XmlToolsShrink the XML content to reduce the file size for a higher performance in automated processing. The following option will be executed: - remove XML comments
- remove whitespace
- remove linebreak
The final result is an XML in one row without comments and whitespace in one line. input and output is not parsed or checked for well formed.- Specified by:
shrinkContentin interfaceXmlTools- Parameters:
content- as String- Returns:
- shrink content as String
-
transformXslt
Description copied from interface:XmlToolsTransform an XML File by a given XSLT to a new Output.- Specified by:
transformXsltin interfaceXmlTools- Parameters:
xml- as Filexslt- as File- Returns:
- transformation as String
-
hasExternalSchemaFile
public boolean hasExternalSchemaFile()Description copied from interface:XmlToolsCheck if a external schema file s configured.- Specified by:
hasExternalSchemaFilein interfaceXmlTools- Returns:
- true on success
-
isValid
public boolean isValid()Description copied from interface:XmlToolsValidate well formed XML content (XML 1.0) against a given grammar. Grammar files can be DTD or XML Schema. THe validation contains also a well formed test for the XML file. -
isWellFormed
public boolean isWellFormed()Description copied from interface:XmlToolsCheck XML content (XML 1.0) if is well formed. the well formed rules for XML are defined as:
- the structure of a XML document is a tree and each node is defined as TAG
- each document contains exact one root tag
- element tags are case-sensitive
- content be delimited with a beginning and end tag
- begin, end, and empty-element tags that delimit the elements are
correctly nested, with none missing and none overlapping Detail
- it contains only properly encoded legal Unicode characters
- special characters like: > < & have to be encoded
(StringUtils.escapeXmlCharacters()) Information: https://en.wikipedia.org/wiki/Well-formed_document- Specified by:
isWellFormedin interfaceXmlTools- Returns:
- true on success
-
resetExternalSchema
public void resetExternalSchema()Description copied from interface:XmlToolsReset the external schema file to NULL.- Specified by:
resetExternalSchemain interfaceXmlTools
-
setSchemaFile
Description copied from interface:XmlToolsSet explicit the schema file for the validation option. This method overwrites in the XML document declares Schemata.- Specified by:
setSchemaFilein interfaceXmlTools- Parameters:
schema- as File
-
writeXmlToFile
Description copied from interface:XmlToolsWrites a XML String into a new file.- Specified by:
writeXmlToFilein interfaceXmlTools- Parameters:
content- as stringdestinationFile- as String- Throws:
IOException
-