A class performing XSLT transformations on XML files and XSD schema validations.
More...
|
static Boolean | validateAgainstXSDSchema (String inputStr, String schemapath) throws SAXException, IOException |
| Validates an XML file given as a String against an XSD schema given by a filepath to it on the harddisk. More...
|
|
static String | gmdToGeoDCAT (String source) throws TransformerException |
| Converts a GMD representation to GeoDCAT using the GDM2GeoDCAT XSLT file. More...
|
|
static String | GeoDCATToHTML (String source) throws TransformerException |
| Performs a transformation from GeoDCAT XML to GeoDCAT in HTML. More...
|
|
A class performing XSLT transformations on XML files and XSD schema validations.
◆ GeoDCATToHTML()
static String GeoDCATToHTML |
( |
String |
source | ) |
throws TransformerException |
|
static |
Performs a transformation from GeoDCAT XML to GeoDCAT in HTML.
- Parameters
-
source | the GeoDCAT XML representation as String |
- Returns
- the HTML representation as a String
- Exceptions
-
TransformerException | when transformation errors occur |
78 System.out.println(
"Source: " + source);
79 InputStreamReader input =
new InputStreamReader(
new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8)));
80 TransformerFactory tFactory =
new net.sf.saxon.TransformerFactoryImpl();
81 Source xmlSource =
new StreamSource(input);
82 Source xslSource =
new StreamSource(
new File(
"dcat-ap-rdf2rdfa.xsl"));
83 StringWriter outWriter =
new StringWriter();
84 StreamResult fOutresult =
new StreamResult( outWriter );
85 Transformer transformer = tFactory.newTransformer(xslSource);
86 transformer.transform(xmlSource, fOutresult);
87 return outWriter.toString();
Referenced by DCATFormatter.formatter().
◆ gmdToGeoDCAT()
static String gmdToGeoDCAT |
( |
String |
source | ) |
throws TransformerException |
|
static |
Converts a GMD representation to GeoDCAT using the GDM2GeoDCAT XSLT file.
- Parameters
-
source | A String representing a GMD XML document |
- Returns
- A GeoDCAT representation as XML
- Exceptions
-
TransformerException | when transformation errors occur |
59 System.out.println(
"Source: " + source);
60 InputStreamReader input =
new InputStreamReader(
new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8)));
61 TransformerFactory tFactory =
new net.sf.saxon.TransformerFactoryImpl();
62 Source xmlSource =
new StreamSource(input);
63 Source xslSource =
new StreamSource(
new File(
"gmd2geodcat.xsl"));
64 StringWriter outWriter =
new StringWriter();
65 StreamResult fOutresult =
new StreamResult( outWriter );
66 Transformer transformer = tFactory.newTransformer(xslSource);
67 transformer.transform(xmlSource, fOutresult);
68 return outWriter.toString();
Referenced by DCATFormatter.formatter().
◆ validateAgainstXSDSchema()
static Boolean validateAgainstXSDSchema |
( |
String |
inputStr, |
|
|
String |
schemapath |
|
) |
| throws SAXException, IOException |
|
static |
Validates an XML file given as a String against an XSD schema given by a filepath to it on the harddisk.
- Parameters
-
inputStr | The XML document to verify |
schemapath | The path to the XSD schema |
- Returns
- True if the validation was successful, False otherwise
- Exceptions
-
SAXException | on parsing errors |
IOException | on reading errors |
38 SchemaFactory factory =
39 SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
40 Schema schema = factory.newSchema(
new File(schemapath));
41 Validator validator = schema.newValidator();
42 InputStreamReader input =
new InputStreamReader(
new ByteArrayInputStream(inputStr.getBytes(StandardCharsets.UTF_8)));
44 validator.validate(
new StreamSource(input));
46 }
catch (SAXException e) {