generated from giis-uniovi/samples-giis-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solved cycle SchemaEvolution and ModelUtilities
- Loading branch information
1 parent
6613c01
commit d48772a
Showing
5 changed files
with
40 additions
and
38 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
modevo-transform/src/main/java/giis/modevo/model/DocumentUtilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package giis.modevo.model; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.xml.XMLConstants; | ||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.w3c.dom.Document; | ||
import org.xml.sax.SAXException; | ||
|
||
public class DocumentUtilities { | ||
public Document readDocumentGeneric (String path) { | ||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | ||
Document doc = null; | ||
// optional, but recommended | ||
// process XML securely, avoid attacks like XML External Entities (XXE) | ||
try { | ||
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); | ||
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); | ||
// parse XML file | ||
DocumentBuilder db = dbf.newDocumentBuilder(); | ||
doc = db.parse(new File(path)); | ||
// optional, but recommended | ||
doc.getDocumentElement().normalize(); | ||
} catch (ParserConfigurationException | SAXException | IOException e) { | ||
throw new DocumentException("A model could not be opened:" + e); | ||
} | ||
return doc; | ||
} | ||
} |
30 changes: 1 addition & 29 deletions
30
modevo-transform/src/main/java/giis/modevo/model/ModelUtilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters