diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-20 02:58:09 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-20 02:58:09 +0000 |
commit | e16b71858955a18e5e82b23eb9c1f920834a2b8f (patch) | |
tree | d49bb24673619237babafdd1f8c8014897642383 /java/sca/modules/assembly | |
parent | 70262376b1dd5d59e1633c9c22250983b5c8a544 (diff) |
Fix for ASM_5026 related property processing
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@806026 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly')
-rw-r--r-- | java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java index b9da3301ea..7a91e4da18 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyConfigurationUtil.java @@ -62,25 +62,25 @@ import org.xml.sax.InputSource; */ abstract class PropertyConfigurationUtil { - /** - * Evaluate an XPath expression against a Property value, returning the result as a Property value - * @param node - the document root element of a Property value - * @param expression - the XPath expression - * @param documentBuilderFactory - a DOM document builder factory - * @return - a DOM Document representing the result of the evaluation as a Property value - * @throws XPathExpressionException - * @throws ParserConfigurationException - */ - private static Document evaluate(Document node, - XPathExpression expression, - DocumentBuilderFactory documentBuilderFactory) throws XPathExpressionException, - ParserConfigurationException { - - // The document element is a <sca:property/> element + /** + * Evaluate an XPath expression against a Property value, returning the result as a Property value + * @param node - the document root element of a Property value + * @param expression - the XPath expression + * @param documentBuilderFactory - a DOM document builder factory + * @return - a DOM Document representing the result of the evaluation as a Property value + * @throws XPathExpressionException + * @throws ParserConfigurationException + */ + private static Document evaluate(Document node, + XPathExpression expression, + DocumentBuilderFactory documentBuilderFactory) throws XPathExpressionException, + ParserConfigurationException { + + // The document element is a <sca:property/> element Node property = node.getDocumentElement(); // The first child of the <property/> element is a <value/> element Node value = property.getFirstChild(); - + Node result = (Node)expression.evaluate(value, XPathConstants.NODE); if (result == null) { return null; @@ -89,25 +89,24 @@ abstract class PropertyConfigurationUtil { if (result instanceof Document) { return (Document)result; } else { - Document document = documentBuilderFactory.newDocumentBuilder().newDocument(); + Document document = documentBuilderFactory.newDocumentBuilder().newDocument(); Element newProperty = document.createElementNS(SCA11_NS, "property"); - - if( "value".equals(result.getLocalName()) ) { - // If the result is a <value/> element, use it directly in the result - newProperty.appendChild(document.importNode(result, true)); + + if (result.getNodeType() == Node.ELEMENT_NODE) { + // If the result is a <value/> element, use it directly in the result + newProperty.appendChild(document.importNode(result, true)); } else { - // If the result is not a <value/> element, create a <value/> element to contain the result - Element newValue = document.createElementNS(SCA11_NS, "value"); - newValue.appendChild(document.importNode(result, true)); - newProperty.appendChild(newValue); + // If the result is not a <value/> element, create a <value/> element to contain the result + Element newValue = document.createElementNS(SCA11_NS, "value"); + newValue.appendChild(document.importNode(result, true)); + newProperty.appendChild(newValue); } // end if document.appendChild(newProperty); - + return document; } } // end method evaluate - private static Document loadFromFile(String file, TransformerFactory transformerFactory) throws MalformedURLException, IOException, TransformerException, ParserConfigurationException { URI uri = URI.create(file); |