List of usage examples for javax.xml.parsers DocumentBuilderFactory setValidating
public void setValidating(boolean validating)
From source file:fi.foyt.fni.materials.MaterialController.java
private org.w3c.dom.Document tidyForPdf(String title, String bodyContent) throws ParserConfigurationException, IOException, SAXException { String documentHtml = HtmlUtils.getAsHtmlText(title, bodyContent); String cleanedHtml = null;// w w w .j a va 2 s . co m ByteArrayOutputStream tidyStream = new ByteArrayOutputStream(); try { Tidy tidy = new Tidy(); tidy.setInputEncoding("UTF-8"); tidy.setOutputEncoding("UTF-8"); tidy.setShowWarnings(true); tidy.setNumEntities(false); tidy.setXmlOut(true); tidy.setXHTML(true); cleanedHtml = HtmlUtils.printDocument(tidy.parseDOM(new StringReader(documentHtml), null)); } catch (Exception e) { throw e; } finally { tidyStream.flush(); tidyStream.close(); } InputStream documentStream = new ByteArrayInputStream(cleanedHtml.getBytes("UTF-8")); try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(false); builderFactory.setValidating(false); builderFactory.setFeature("http://xml.org/sax/features/namespaces", false); builderFactory.setFeature("http://xml.org/sax/features/validation", false); builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.parse(documentStream); } finally { documentStream.close(); } }
From source file:com.amalto.workbench.utils.Util.java
/** * Returns and XSDSchema Object from an xsd * /*ww w . jav a2 s . c om*/ * @param schema * @return * @throws Exception */ public static XSDSchema getXSDSchema(String schema) throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); StringReader reader = new StringReader(schema); InputSource source = new InputSource(new StringReader(schema)); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(source); XSDSchema xsdSchema = null; xsdSchema = XSDSchemaImpl.createSchema(document.getDocumentElement()); reader.close(); return xsdSchema; }
From source file:com.amalto.workbench.utils.Util.java
public static Document parse(String xmlString, String schema) throws Exception { // parse//from w w w . j a va 2 s. c o m Document d = null; SAXErrorHandler seh = new SAXErrorHandler(); try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating((schema != null)); documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", //$NON-NLS-1$ "http://www.w3.org/2001/XMLSchema");//$NON-NLS-1$ if (schema != null) { documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", //$NON-NLS-1$ new InputSource(new StringReader(schema))); } DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); documentBuilder.setErrorHandler(seh); if (xmlString == null || xmlString.length() == 0 || xmlString.matches("\\s+")) { return d; } d = documentBuilder.parse(new InputSource(new StringReader(xmlString))); if (schema != null) { String errors = seh.getErrors(); if (!errors.equals("")) {//$NON-NLS-1$ String err = Messages.Util_12 + errors + Messages.Util_13; throw new Exception(err); } } return d; } catch (Exception e) { log.error(e.getMessage(), e); String err = Messages.Util_14 + Messages.Util_15 + e.getClass().getName() + Messages.Util_16 + e.getLocalizedMessage() + Messages.Util_17 + xmlString; throw new Exception(err); } }
From source file:com.amalto.workbench.utils.Util.java
private static XSDSchema getXSDSchema(String namespaceURI, String rawData, final List<XSDImport> imports, final TreeObject treeObj, boolean uri, final List<Exception> exceptions, final Map<String, Integer> schemaMonitor) throws Exception { FileInputStream fin = null;/*from www . ja v a 2 s . c o m*/ try { final String xsdFileName = System.getProperty("user.dir") + "/.xsdModel.xml";//$NON-NLS-1$//$NON-NLS-2$ URI fileURI = URI.createFileURI(xsdFileName); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); DocumentBuilder documentBuilder; XSDSchema schema = null; InputSource source = null; Document document = null; String schemaLocation = rawData; documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (rawData == null) { return XSDSchemaImpl.getSchemaForSchema("http://www.w3.org/2001/XMLSchema");//$NON-NLS-1$ } if (namespaceURI == null && rawData.endsWith(".xsd") && rawData.indexOf(File.separator) > 0) {//$NON-NLS-1$ File rawFile = new File(rawData); if (!rawFile.exists()) { throw new IllegalArgumentException(rawData); } } // import namespace="http://xxx" schemaLocation="xxxx" if (namespaceURI != null && schemaLocation.endsWith(".xsd")) {//$NON-NLS-1$ URL url = new java.net.URI(namespaceURI + "/" + rawData).toURL();//$NON-NLS-1$ uri = false; rawData = IOUtils.toString(url.openConnection().getInputStream()); rawData = rawData.replaceAll("<!DOCTYPE(.*?)>", "");//$NON-NLS-1$//$NON-NLS-2$ } if (rawData.equals("http://www.w3.org/2001/03/xml.xsd")) {//$NON-NLS-1$ URL url = new java.net.URI("http://www.w3.org/2001/03/xml.xsd").toURL();//$NON-NLS-1$ uri = false; rawData = IOUtils.toString(url.openConnection().getInputStream()); rawData = rawData.replaceAll("<!DOCTYPE(.*?)>", "");//$NON-NLS-1$//$NON-NLS-2$ } if (uri) { File file = new File(rawData); if (file.exists()) { fin = new FileInputStream(file); source = new InputSource(fin); } else { source = new InputSource(new StringReader(Util.getResponseFromURL(rawData, treeObj))); } } else { source = new InputSource(new StringReader(rawData)); } try { document = documentBuilder.parse(source); } catch (SAXParseException ex) { exceptions.add(ex); return null; } schema = XSDSchemaImpl.createSchema(document.getDocumentElement()); ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = resourceSet.createResource(fileURI); resourceSet.getAdapterFactories().add(new AdapterFactoryImpl() { class SchemaLocator extends AdapterImpl implements XSDSchemaLocator { public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI, String rawSchemaLocationURI, String resolvedSchemaLocation) { XSDSchema schema; Integer rawCnt = schemaMonitor.get(rawSchemaLocationURI); if (rawCnt == null) { rawCnt = 0; } else { rawCnt++; } schemaMonitor.put(rawSchemaLocationURI, rawCnt); if (rawCnt >= 10) { schemaMonitor.put(rawSchemaLocationURI, -1); return null; } try { schema = Util.getXSDSchema(namespaceURI, rawSchemaLocationURI, imports, treeObj, true, exceptions, schemaMonitor); } catch (Exception e) { return XSDSchemaImpl.getSchemaForSchema(namespaceURI); } schema.setTargetNamespace(namespaceURI); schema.setElement(schema.getDocument().getDocumentElement()); return schema; } public boolean isAdatperForType(Object type) { return type == XSDSchemaLocator.class; } } protected SchemaLocator schemaLocator = new SchemaLocator(); @Override public boolean isFactoryForType(Object type) { return type == XSDSchemaLocator.class; } @Override public Adapter adaptNew(Notifier target, Object type) { return schemaLocator; } }); // import namespace="http://xxx" schemaLocation="xxxx" if (namespaceURI != null && schemaLocation.endsWith(".xsd")) {//$NON-NLS-1$ schema.setSchemaLocation(schemaLocation); } else { schema.setSchemaLocation(fileURI.toString()); // set the schema for schema QName prefix to "xsd" schema.setSchemaForSchemaQNamePrefix("xsd");//$NON-NLS-1$ } // catch up the NPE to make sure data model can still run in case of unknown conflict try { resource.getContents().add(schema); } catch (Exception ex) { log.error(ex.getMessage(), ex); } // Add the root schema to the resource that was created above Iterator<Integer> iter = schemaMonitor.values().iterator(); while (iter.hasNext()) { Integer it = iter.next(); if (it.intValue() == -1) { return schema; } } importSchema(schema, imports, schemaMonitor); schema.setElement(document.getDocumentElement()); return schema; } finally { if (fin != null) { fin.close(); } } }
From source file:com.ext.portlet.epsos.EpsosHelperService.java
public static String getPortalTranslation(String key, String language) { String translation = ""; language = language.replaceAll("_", "-"); try {//w w w.jav a2 s . c o m ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL url = cl.getResource("content/language/application/" + language + "/SpiritEhrPortal.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(url.getFile()); doc.getDocumentElement().normalize(); XPath xpath = XPathFactory.newInstance().newXPath(); translation = xpath.evaluate("//*[@key='" + key + "']", doc); if (Validator.isNull(translation)) translation = key; } catch (Exception e) { Log.error(e.getMessage()); } return translation; }
From source file:com.ext.portlet.epsos.EpsosHelperService.java
public static String getConsentText(String language) { String translation = ""; language = language.replaceAll("_", "-"); try {//from ww w .ja v a2s . c o m ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL url = cl.getResource("content/language/consent/Consent_LegalText_" + language + ".xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(url.getFile()); doc.getDocumentElement().normalize(); XPath xpath = XPathFactory.newInstance().newXPath(); String xpathExpression = "/Consent/LegalText"; NodeList nodes = (NodeList) xpath.evaluate(xpathExpression, doc, XPathConstants.NODESET); translation = nodes.item(0).getTextContent(); } catch (Exception e) { Log.error("Error getting consent text for country " + language); } return translation; }
From source file:com.amalto.workbench.editors.DataModelMainPage.java
/** * Returns and XSDSchema Object from an xsd * // w ww .j a va2s. c o m * @param schema * @return * @throws Exception */ public XSDSchema getXSDSchema(String schema) throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); InputSource source = new InputSource(new StringReader(schema)); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); try { Document document = documentBuilder.parse(source); if (xsdSchema == null) { xsdSchema = Util.createXsdSchema(schema, xobject); } else { xsdSchema.setDocument(document); } } catch (SAXParseException e) { // log.error(e.getMessage(), e); return null; } return xsdSchema; }
From source file:com.amalto.workbench.editors.DataModelMainPage.java
protected void importSchema(InputSource source, String uri) throws Exception { String ns = "";//$NON-NLS-1$ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(source); ns = document.getDocumentElement().getAttribute("targetNamespace");//$NON-NLS-1$ if (xsdSchema == null) { xsdSchema = getXSDSchema(Util.nodeToString(document)); } else {/*from ww w. j a va2 s . co m*/ WSDataModel wsObject = (WSDataModel) (xobject.getWsObject()); xsdSchema = Util.createXsdSchema(wsObject.getXsdSchema(), xobject); } boolean exist = false; for (int i = 0; i < xsdSchema.getContents().size(); i++) { XSDSchemaContent xsdComp = xsdSchema.getContents().get(i); if (ns != null && !ns.equals("")) {//$NON-NLS-1$ // import xsdschema if (xsdComp instanceof XSDImport && ((XSDImport) xsdComp).getNamespace().equals(ns)) { for (Map.Entry entry : xsdSchema.getQNamePrefixToNamespaceMap().entrySet()) { if (entry.getValue().equals(((XSDImport) xsdComp).getNamespace())) { exist = true; break; } } break; } } else { // include xsdschema if (xsdComp instanceof XSDInclude) { String xsdLocation = ((XSDInclude) xsdComp).getSchemaLocation(); if (xsdLocation.equals(uri)) { exist = true; break; } } } } if (!exist) { if (ns != null && !ns.equals("")) {//$NON-NLS-1$ int last = ns.lastIndexOf("/");//$NON-NLS-1$ xsdSchema.getQNamePrefixToNamespaceMap().put(ns.substring(last + 1).replaceAll("[\\W]", ""), ns);//$NON-NLS-1$//$NON-NLS-2$ XSDImport xsdImport = XSDFactory.eINSTANCE.createXSDImport(); xsdImport.setNamespace(ns); xsdImport.setSchemaLocation(uri); xsdSchema.getContents().add(0, xsdImport); } else { XSDInclude xsdInclude = XSDFactory.eINSTANCE.createXSDInclude(); xsdInclude.setSchemaLocation(uri); xsdSchema.getContents().add(0, xsdInclude); } String xsd = Util.nodeToString(xsdSchema.getDocument()); setXsdSchema(xsdSchema); WSDataModel wsObject = (WSDataModel) (xobject.getWsObject()); wsObject.setXsdSchema(xsd); } }
From source file:de.interactive_instruments.ShapeChange.Options.java
public void loadConfiguration() throws ShapeChangeAbortException { InputStream configStream = null; if (configFile == null) { // load minimal configuration, if no configuration file has been // provided configFile = "/config/minimal.xml"; configStream = getClass().getResourceAsStream(configFile); if (configStream == null) { configFile = "src/main/resources" + configFile; File file = new File(configFile); if (file.exists()) try { configStream = new FileInputStream(file); } catch (FileNotFoundException e1) { throw new ShapeChangeAbortException("Minimal configuration file not found: " + configFile); }//from w w w . j a v a2 s.c o m else { URL url; String configURL = "http://shapechange.net/resources/config/minimal.xml"; try { url = new URL(configURL); configStream = url.openStream(); } catch (MalformedURLException e) { throw new ShapeChangeAbortException("Minimal configuration file not accessible from: " + configURL + " (malformed URL)"); } catch (IOException e) { throw new ShapeChangeAbortException( "Minimal configuration file not accessible from: " + configURL + " (IO error)"); } } } } else { File file = new File(configFile); if (file == null || !file.exists()) { try { configStream = (new URL(configFile)).openStream(); } catch (MalformedURLException e) { throw new ShapeChangeAbortException( "No configuration file found at " + configFile + " (malformed URL)"); } catch (IOException e) { throw new ShapeChangeAbortException( "No configuration file found at " + configFile + " (IO exception)"); } } else { try { configStream = new FileInputStream(file); } catch (FileNotFoundException e) { throw new ShapeChangeAbortException("No configuration file found at " + configFile); } } if (configStream == null) { throw new ShapeChangeAbortException("No configuration file found at " + configFile); } } DocumentBuilder builder = null; ShapeChangeErrorHandler handler = null; try { System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setFeature("http://apache.org/xml/features/validation/schema", true); factory.setIgnoringElementContentWhitespace(true); factory.setIgnoringComments(true); factory.setXIncludeAware(true); factory.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false); builder = factory.newDocumentBuilder(); handler = new ShapeChangeErrorHandler(); builder.setErrorHandler(handler); } catch (FactoryConfigurationError e) { throw new ShapeChangeAbortException("Unable to get a document builder factory."); } catch (ParserConfigurationException e) { throw new ShapeChangeAbortException("XML Parser was unable to be configured."); } // parse file try { Document document = builder.parse(configStream); if (handler.errorsFound()) { throw new ShapeChangeAbortException("Invalid configuration file."); } // parse input element specific content NodeList nl = document.getElementsByTagName("input"); Element inputElement = (Element) nl.item(0); if (inputElement.hasAttribute("id")) { inputId = inputElement.getAttribute("id").trim(); if (inputId.length() == 0) { inputId = null; } } else { inputId = Options.INPUTELEMENTID; } Map<String, String> inputParameters = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("parameter"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("name"); String val = e.getAttribute("value"); inputParameters.put(key, val); } Map<String, String> stereotypeAliases = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("StereotypeAlias"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("alias"); String val = e.getAttribute("wellknown"); // case shall be ignored key = key.toLowerCase(); val = val.toLowerCase(); stereotypeAliases.put(key, val); } Map<String, String> tagAliases = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("TagAlias"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("alias"); String val = e.getAttribute("wellknown"); // case not to be ignored for tagged values at the moment // key = key.toLowerCase(); // val = val.toLowerCase(); tagAliases.put(key, val); } Map<String, String> descriptorSources = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("DescriptorSource"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("descriptor"); String val = e.getAttribute("source"); // case shall be ignored for descriptor and source key = key.toLowerCase(); val = val.toLowerCase(); if (val.equals("sc:extract")) { String s = e.getAttribute("token"); val += "#" + (s == null ? "" : s); } else if (val.equals("tag")) { String s = e.getAttribute("tag"); val += "#" + (s == null ? "" : s); } descriptorSources.put(key, val); } Map<String, PackageInfoConfiguration> packageInfos = parsePackageInfos(inputElement); this.inputConfig = new InputConfiguration(inputId, inputParameters, stereotypeAliases, tagAliases, descriptorSources, packageInfos); // parse dialog specific parameters nl = document.getElementsByTagName("dialog"); if (nl != null && nl.getLength() != 0) { for (int k = 0; k < nl.getLength(); k++) { Node node = nl.item(k); if (node.getNodeType() == Node.ELEMENT_NODE) { Element dialogElement = (Element) node; this.dialogParameters = parseParameters(dialogElement, "parameter"); } } } // parse log specific parameters nl = document.getElementsByTagName("log"); if (nl != null && nl.getLength() != 0) { for (int k = 0; k < nl.getLength(); k++) { Node node = nl.item(k); if (node.getNodeType() == Node.ELEMENT_NODE) { Element logElement = (Element) node; this.logParameters = parseParameters(logElement, "parameter"); } } } // add standard rules, just so that configured rules can be // validated addStandardRules(); // Load transformer configurations (if any are provided in the // configuration file) Map<String, TransformerConfiguration> transformerConfigs = parseTransformerConfigurations(document); // Load target configurations this.targetConfigs = parseTargetConfigurations(document); this.resetFields(); // this.resetUponLoadFlag = false; // TBD discuss if there's a better way to support rule and // requirements matching for the input model // TBD apparently the matching requires all // applicable encoding rules to be known up front for (TargetConfiguration tgtConfig : targetConfigs) { // System.out.println(tgtConfig); String className = tgtConfig.getClassName(); String mode = tgtConfig.getProcessMode().name(); // set targets and their mode; if a target occurs multiple // times, keep the enabled one(s) if (!this.fTargets.containsKey(className)) { addTarget(className, mode); } else { if (this.fTargets.get(className).equals(ProcessMode.disabled)) { // set targets and their mode; if a target occurs // multiple times, keep the enabled one(s) addTarget(className, mode); } } // ensure that we have all the rules from all non-disabled // targets // we repeat this for the same target (if it is not disabled) to // ensure that we get the union of all encoding rules if (!tgtConfig.getProcessMode().equals(ProcessMode.disabled)) { for (ProcessRuleSet prs : tgtConfig.getRuleSets().values()) { String nam = prs.getName(); String ext = prs.getExtendedRuleSetName(); addExtendsEncRule(nam, ext); if (prs.hasAdditionalRules()) { for (String rule : prs.getAdditionalRules()) { addRule(rule, nam); } } } } /* * looks like we also need parameters like defaultEncodingRule * !!! IF THERE ARE DIFFERENT DEFAULT ENCODING RULES FOR * DIFFERENT TARGETS (WITH SAME CLASS) THIS WONT WORK!!! */ for (String paramName : tgtConfig.getParameters().keySet()) { setParameter(className, paramName, tgtConfig.getParameters().get(paramName)); } // in order for the input model load not to produce warnings, // we also need to load the map entries if (tgtConfig instanceof TargetXmlSchemaConfiguration) { TargetXmlSchemaConfiguration config = (TargetXmlSchemaConfiguration) tgtConfig; // add xml schema namespace information for (XmlNamespace xns : config.getXmlNamespaces()) { addNamespace(xns.getNsabr(), xns.getNs(), xns.getLocation()); // if (xns.getLocation() != null) { addSchemaLocation(xns.getNs(), xns.getLocation()); // } } // add xsd map entries for (XsdMapEntry xsdme : config.getXsdMapEntries()) { for (String xsdEncodingRule : xsdme.getEncodingRules()) { String type = xsdme.getType(); String xmlPropertyType = xsdme.getXmlPropertyType(); String xmlElement = xsdme.getXmlElement(); String xmlTypeContent = xsdme.getXmlTypeContent(); String xmlTypeNilReason = xsdme.getXmlTypeNilReason(); String xmlType = xsdme.getXmlType(); String xmlTypeType = xsdme.getXmlTypeType(); String xmlAttribute = xsdme.getXmlAttribute(); String xmlAttributeGroup = xsdme.getXmlAttributeGroup(); if (xmlPropertyType != null) { if (xmlPropertyType.equals("_P_") && xmlElement != null) { addTypeMapEntry(type, xsdEncodingRule, "propertyType", xmlElement); } else if (xmlPropertyType.equals("_MP_") && xmlElement != null) { addTypeMapEntry(type, xsdEncodingRule, "metadataPropertyType", xmlElement); } else { addTypeMapEntry(type, xsdEncodingRule, "direct", xmlPropertyType, xmlTypeType + "/" + xmlTypeContent, xmlTypeNilReason); } } if (xmlElement != null) { addElementMapEntry(type, xsdEncodingRule, "direct", xmlElement); } if (xmlType != null) { addBaseMapEntry(type, xsdEncodingRule, "direct", xmlType, xmlTypeType + "/" + xmlTypeContent); } if (xmlAttribute != null) { addAttributeMapEntry(type, xsdEncodingRule, xmlAttribute); } if (xmlAttributeGroup != null) { addAttributeGroupMapEntry(type, xsdEncodingRule, xmlAttributeGroup); } } } } else { // add map entries for Target (no need to do this for // transformers) for (ProcessMapEntry pme : tgtConfig.getMapEntries()) { addTargetTypeMapEntry(tgtConfig.getClassName(), pme.getType(), pme.getRule(), pme.getTargetType(), pme.getParam()); } } } // create "tree" for (TargetConfiguration tgtConfig : targetConfigs) { for (String inputIdref : tgtConfig.getInputIds()) { if (inputIdref.equals(getInputId())) { this.inputTargetConfigs.add(tgtConfig); } else { transformerConfigs.get(inputIdref).addTarget(tgtConfig); } } } for (TransformerConfiguration trfConfig : transformerConfigs.values()) { String inputIdref = trfConfig.getInputId(); if (inputIdref.equals(getInputId())) { this.inputTransformerConfigs.add(trfConfig); } else { transformerConfigs.get(inputIdref).addTransformer(trfConfig); } } // Determine constraint creation handling parameters: String classTypesToCreateConstraintsFor = parameter("classTypesToCreateConstraintsFor"); if (classTypesToCreateConstraintsFor != null) { classTypesToCreateConstraintsFor = classTypesToCreateConstraintsFor.trim(); if (classTypesToCreateConstraintsFor.length() > 0) { String[] stereotypes = classTypesToCreateConstraintsFor.split("\\W*,\\W*"); this.classTypesToCreateConstraintsFor = new HashSet<Integer>(); for (String stereotype : stereotypes) { String sForCons = stereotype.toLowerCase(); if (sForCons.equals("enumeration")) { this.classTypesToCreateConstraintsFor.add(new Integer(ENUMERATION)); } else if (sForCons.equals("codelist")) { this.classTypesToCreateConstraintsFor.add(new Integer(CODELIST)); } else if (sForCons.equals("schluesseltabelle")) { this.classTypesToCreateConstraintsFor.add(new Integer(OKSTRAKEY)); } else if (sForCons.equals("fachid")) { this.classTypesToCreateConstraintsFor.add(new Integer(OKSTRAFID)); } else if (sForCons.equals("datatype")) { this.classTypesToCreateConstraintsFor.add(new Integer(DATATYPE)); } else if (sForCons.equals("union")) { this.classTypesToCreateConstraintsFor.add(new Integer(UNION)); } else if (sForCons.equals("featureconcept")) { this.classTypesToCreateConstraintsFor.add(new Integer(FEATURECONCEPT)); } else if (sForCons.equals("attributeconcept")) { this.classTypesToCreateConstraintsFor.add(new Integer(ATTRIBUTECONCEPT)); } else if (sForCons.equals("valueconcept")) { this.classTypesToCreateConstraintsFor.add(new Integer(VALUECONCEPT)); } else if (sForCons.equals("interface")) { this.classTypesToCreateConstraintsFor.add(new Integer(MIXIN)); } else if (sForCons.equals("basictype")) { this.classTypesToCreateConstraintsFor.add(new Integer(BASICTYPE)); } else if (sForCons.equals("adeelement")) { this.classTypesToCreateConstraintsFor.add(new Integer(FEATURE)); } else if (sForCons.equals("featuretype")) { this.classTypesToCreateConstraintsFor.add(new Integer(FEATURE)); } else if (sForCons.equals("type")) { this.classTypesToCreateConstraintsFor.add(new Integer(OBJECT)); } else { this.classTypesToCreateConstraintsFor.add(new Integer(UNKNOWN)); } } } } String constraintCreationForProperties = parameter("constraintCreationForProperties"); if (constraintCreationForProperties != null) { if (constraintCreationForProperties.trim().equalsIgnoreCase("false")) { this.constraintCreationForProperties = false; } } /* * TODO add documentation */ String ignoreEncodingRuleTaggedValues = parameter("ignoreEncodingRuleTaggedValues"); if (ignoreEncodingRuleTaggedValues != null) { if (ignoreEncodingRuleTaggedValues.trim().equalsIgnoreCase("true")) { this.ignoreEncodingRuleTaggedValues = true; } } String useStringInterning_value = parameter(PARAM_USE_STRING_INTERNING); if (useStringInterning_value != null && useStringInterning_value.trim().equalsIgnoreCase("true")) { this.useStringInterning = true; } String loadGlobalIds_value = this.parameter(PARAM_LOAD_GLOBAL_IDENTIFIERS); if (loadGlobalIds_value != null && loadGlobalIds_value.trim().equalsIgnoreCase("true")) { this.loadGlobalIds = true; } String language_value = inputConfig.getParameters().get(PARAM_LANGUAGE); if (language_value != null && !language_value.trim().isEmpty()) { this.language = language_value.trim().toLowerCase(); } } catch (SAXException e) { String m = e.getMessage(); if (m != null) { throw new ShapeChangeAbortException( "Error while loading configuration file: " + System.getProperty("line.separator") + m); } else { e.printStackTrace(System.err); throw new ShapeChangeAbortException("Error while loading configuration file: " + System.getProperty("line.separator") + System.err); } } catch (IOException e) { String m = e.getMessage(); if (m != null) { throw new ShapeChangeAbortException( "Error while loading configuration file: " + System.getProperty("line.separator") + m); } else { e.printStackTrace(System.err); throw new ShapeChangeAbortException("Error while loading configuration file: " + System.getProperty("line.separator") + System.err); } } MapEntry nsme = namespace("gml"); if (nsme != null) { GML_NS = nsme.rule; } }