Permalink
Browse files

Små refactorings.

  • Loading branch information...
1 parent 1d444a7 commit 7079a9e038ad3fb087a0cc92f96ac6a28b5f7355 @usktrifork usktrifork committed Apr 18, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/dk/medicinkortet/xmlschema/FlattenWsdl.java
@@ -29,6 +29,7 @@
public class FlattenWsdl {
private static final String NS_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+ private TransformerFactory transformerFactory = TransformerFactory.newInstance();
private DocumentBuilderFactory documentBuilderFactory;
private Node typesNode;
@@ -81,6 +82,7 @@ public static void main(String[] args) {
}
private FlattenWsdl() {
+ transformerFactory = TransformerFactory.newInstance();
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
}
@@ -102,7 +104,7 @@ private void run(String input, String output) {
}
wsdlDocument.normalizeDocument();
- Transformer trans = TransformerFactory.newInstance().newTransformer();
+ Transformer trans = transformerFactory.newTransformer();
StreamResult streamResult = new StreamResult(new File(output));
trans.transform(new DOMSource(wsdlDocument.getDocumentElement()), streamResult);
@@ -364,7 +366,7 @@ private void insertSchemaFileIntoSchemaElement(SchemaFile schemaFile, DOMResult
throw new RuntimeException("dom == null for schemaLocation=" + schemaFile.location);
}
- Transformer trans = TransformerFactory.newInstance().newTransformer();
+ Transformer transformer = transformerFactory.newTransformer();
NodeList childNodeList = schemaFile.domSchemaNode.getChildNodes();
for (int i=0; i<childNodeList.getLength(); i++) {
@@ -382,10 +384,10 @@ private void insertSchemaFileIntoSchemaElement(SchemaFile schemaFile, DOMResult
}
System.out.println(" <import namespace='" + namespaceNode.getNodeValue() + "'/>");
importedNamespaces.add(namespaceNode.getNodeValue());
- trans.transform(new DOMSource(node), schemaElementResult);
+ transformer.transform(new DOMSource(node), schemaElementResult);
}
} else if (!imports) {
- trans.transform(new DOMSource(node), schemaElementResult);
+ transformer.transform(new DOMSource(node), schemaElementResult);
}
}

0 comments on commit 7079a9e

Please sign in to comment.