aboutsummaryrefslogtreecommitdiff
path: root/common/src/at/gv/egovernment/moa/util
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/at/gv/egovernment/moa/util')
-rw-r--r--common/src/at/gv/egovernment/moa/util/XPathUtils.java50
1 files changed, 23 insertions, 27 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
index 7c412567a..dfb14697b 100644
--- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
@@ -420,10 +420,14 @@ public class XPathUtils {
/**
* Return the SecurityLayer namespace prefix of the context element.
- * If the context element has no prefix explicitely set (i.e. is specified
- * within the <code>default</code> namespace), the method sets the prefix
- * according to the value of the <code>xmlns</code> attribute of the context
- * element.
+ * The method sets the prefix according to the value of the
+ * namespace URI of the context element:
+ * <ul>
+ * <li>&quot;http://www.buergerkarte.at/namespaces/securitylayer/20020225#&quot; = &quot;sl10&quot;</li>
+ * <li>&quot;http://www.buergerkarte.at/namespaces/securitylayer/20020831#&quot; = &quot;sl11&quot;</li>
+ * <li>&quot;http://www.buergerkarte.at/namespaces/securitylayer/1.2# = &quot;sl&quot;</li>
+ * <ul>
+ *
* The returned prefix is needed for evaluating XPATH expressions.
*
* @param contextElement The element to get a prefix from.
@@ -431,34 +435,26 @@ public class XPathUtils {
* @return The string <code>sl10</code>, <code>sl11</code> or <code>sl</code>,
* depending on the SecurityLayer namespace of the contextElement.
*
- * throws XpathException If the element has no prefix or no valid SecurityLayer
- * namespace is used as default namespace.
- */
+ * throws XpathException If namespace of context element is not a valid
+ * SecurityLayer namespace.
+ */
public static String getSlPrefix (Element contextElement) throws XPathException {
- String slPrefix = contextElement.getPrefix();
- if (slPrefix != null) {
- return slPrefix;
+ String slPrefix;
+ String nameSpace = contextElement.getNamespaceURI();
+ if (nameSpace.equals(Constants.SL10_NS_URI)) {
+ slPrefix = Constants.SL10_PREFIX;
+ } else if (nameSpace.equals(Constants.SL12_NS_URI)) {
+ slPrefix = Constants.SL12_PREFIX;
+ } else if (nameSpace.equals(Constants.SL11_NS_URI)) {
+ slPrefix = Constants.SL11_PREFIX;
} else {
- String nameSpace = contextElement.getAttribute("xmlns");
-
- if (nameSpace.equals(Constants.SL10_NS_URI)) {
- slPrefix = Constants.SL10_PREFIX;
- } else if (nameSpace.equals(Constants.SL12_NS_URI)) {
- slPrefix = Constants.SL12_PREFIX;
- } else if (nameSpace.equals(Constants.SL11_NS_URI)) {
- slPrefix = Constants.SL11_PREFIX;
- } else {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
- throw new XPathException(message, null);
-
- }
-
- return slPrefix;
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ throw new XPathException(message, null);
}
+ return slPrefix;
}
-
/**
* Return the SecurityLayer namespace prefix of the context element.
* If the context element is not the element that lies within the