Class QNameUtils

java.lang.Object
org.springframework.xml.namespace.QNameUtils

public abstract class QNameUtils extends Object
Helper class for using QName.
Since:
1.0.0
See Also:
  • Constructor Details

    • QNameUtils

      public QNameUtils()
  • Method Details

    • validateQName

      public static boolean validateQName(@Nullable String text)
      Validates the given String as a QName.
      Parameters:
      text - the qualified name
      Returns:
      true if valid, false otherwise
    • getQNameForNode

      public static QName getQNameForNode(Node node)
      Returns the qualified name of the given DOM Node.
      Parameters:
      node - the node
      Returns:
      the qualified name of the node
    • toQualifiedName

      public static String toQualifiedName(QName qName)
      Convert a QName to a qualified name, as used by DOM and SAX. The returned string has a format of prefix:localName if the prefix is set, or just localName if not.
      Parameters:
      qName - the QName
      Returns:
      the qualified name
    • toQName

      public static QName toQName(String namespaceUri, String qualifiedName)
      Convert a namespace URI and DOM or SAX qualified name to a QName. The qualified name can have the form prefix:localname or localName.
      Parameters:
      namespaceUri - the namespace URI
      qualifiedName - the qualified name
      Returns:
      a QName
    • parseQNameString

      public static QName parseQNameString(String qNameString)
      Parse the given qualified name string into a QName. Expects the syntax localPart, {namespace}localPart, or {namespace}prefix:localPart. This format resembles the toString() representation of QName itself, but allows for prefixes to be specified as well.
      Returns:
      a corresponding QName instance
      Throws:
      IllegalArgumentException - when the given string is null or empty.