diff options
author | harald.bratko <harald.bratko@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2006-04-27 13:04:16 +0000 |
---|---|---|
committer | harald.bratko <harald.bratko@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2006-04-27 13:04:16 +0000 |
commit | d28ec7c9b309325d47e3cd3a99a4ae2cba269098 (patch) | |
tree | cdc063b85d525189c50e4fde3d79712995cfeb9e | |
parent | 046acaa65129860b54d2ce782bdf174a0ebc9f6c (diff) | |
download | moa-id-spss-d28ec7c9b309325d47e3cd3a99a4ae2cba269098.tar.gz moa-id-spss-d28ec7c9b309325d47e3cd3a99a4ae2cba269098.tar.bz2 moa-id-spss-d28ec7c9b309325d47e3cd3a99a4ae2cba269098.zip |
Changed method getSLPrefix to in all cases retrieve SecurityLayer namespace
from the namespace uri - and not use the actual prefix if present.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@705 d688527b-c9ab-4aba-bd8d-4036d912da1d
-rw-r--r-- | common/src/at/gv/egovernment/moa/util/XPathUtils.java | 50 |
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>"http://www.buergerkarte.at/namespaces/securitylayer/20020225#" = "sl10"</li> + * <li>"http://www.buergerkarte.at/namespaces/securitylayer/20020831#" = "sl11"</li> + * <li>"http://www.buergerkarte.at/namespaces/securitylayer/1.2# = "sl"</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 |