diff options
-rw-r--r-- | common/src/at/gv/egovernment/moa/util/XPathUtils.java | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java index dfb14697b..bfd91542c 100644 --- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java +++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java @@ -40,9 +40,7 @@ public class XPathUtils { SimpleNamespaceContext ctx = new SimpleNamespaceContext(); ctx.addNamespace(Constants.MOA_PREFIX, Constants.MOA_NS_URI); ctx.addNamespace(Constants.MOA_CONFIG_PREFIX, Constants.MOA_CONFIG_NS_URI); - ctx.addNamespace( - Constants.MOA_ID_CONFIG_PREFIX, - Constants.MOA_ID_CONFIG_NS_URI); + ctx.addNamespace(Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI); ctx.addNamespace(Constants.SL10_PREFIX, Constants.SL10_NS_URI); ctx.addNamespace(Constants.SL11_PREFIX, Constants.SL11_NS_URI); ctx.addNamespace(Constants.SL12_PREFIX, Constants.SL12_NS_URI); @@ -53,9 +51,7 @@ public class XPathUtils { ctx.addNamespace(Constants.DSIG_PREFIX, Constants.DSIG_NS_URI); ctx.addNamespace(Constants.XSLT_PREFIX, Constants.XSLT_NS_URI); ctx.addNamespace(Constants.XSI_PREFIX, Constants.XSI_NS_URI); - ctx.addNamespace( - Constants.DSIG_FILTER2_PREFIX, - Constants.DSIG_FILTER2_NS_URI); + ctx.addNamespace(Constants.DSIG_FILTER2_PREFIX, Constants.DSIG_FILTER2_NS_URI); ctx.addNamespace(Constants.DSIG_EC_PREFIX, Constants.DSIG_EC_NS_URI); ctx.addNamespace(Constants.MD_PREFIX, Constants.MD_NS_URI); ctx.addNamespace(Constants.MDP_PREFIX, Constants.MDP_NS_URI); @@ -419,42 +415,50 @@ public class XPathUtils { } /** - * Return the SecurityLayer namespace prefix 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> + * Returns the namespace prefix used within <code>XPathUtils</code> for referring to + * the namespace of the specified (Security Layer command) element. * - * The returned prefix is needed for evaluating XPATH expressions. + * This namespace prefix can be used in various XPath expression evaluation methods + * within <code> XPathUtils</code> without explicitely binding it to the particular + * namespace. * - * @param contextElement The element to get a prefix from. + * @param contextElement The (Security Layer command) element. * - * @return The string <code>sl10</code>, <code>sl11</code> or <code>sl</code>, - * depending on the SecurityLayer namespace of the contextElement. + * @return the namespace prefix used within <code>XPathUtils</code> for referring to + * the namespace of the specified (Security Layer command) element. * - * throws XpathException If namespace of context element is not a valid - * SecurityLayer namespace. - */ - public static String getSlPrefix (Element contextElement) throws XPathException { - 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 { + * throws XpathException If the specified element has a namespace other than the ones + * known by this implementation as valid Security Layer namespaces (cf. + * @link Constants#SL10_NS_URI, @link Constants#SL11_NS_URI, @link Constants#SL12_NS_URI). + */ + public static String getSlPrefix (Element contextElement) throws XPathException + { + String sLNamespace = contextElement.getNamespaceURI(); + String sLPrefix = null; + + if (sLNamespace.equals(Constants.SL10_NS_URI)) + { + sLPrefix = Constants.SL10_PREFIX; + } + else if (sLNamespace.equals(Constants.SL11_NS_URI)) + { + sLPrefix = Constants.SL11_PREFIX; + } + else if (sLNamespace.equals(Constants.SL12_NS_URI)) + { + sLPrefix = Constants.SL12_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; + String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger Security Layer Namespace: \"" + sLNamespace + "\"."}); + 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 |