Class XMLToken

java.lang.Object
org.basex.util.XMLToken

public final class XMLToken extends Object
This class provides convenience operations for XML-specific character operations.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    decode(byte[] name, boolean lax)
    Decodes an NCName to a string.
    static byte[]
    encode(byte[] name, boolean lax)
    Encodes a string to a valid NCName.
    static byte[]
    getEntity(byte[] key)
    Returns the unicode for the specified entity or null.
    static boolean
    isChar(int ch)
    Checks if the specified character is an XML letter.
    static boolean
    isId(byte[] name, boolean idref)
    Checks if the specified name is an id/idref attribute (idref: local name must contain 'idref'; id: local name must contain 'if', but not 'idref').
    static boolean
    isName(byte[] value)
    Checks if the specified token is a valid name.
    static boolean
    isNCChar(int ch)
    Checks if the specified character is an XML letter.
    static boolean
    isNCName(byte[] value)
    Checks if the specified token is a valid NCName.
    static boolean
    isNCStartChar(int ch)
    Checks if the specified character is a name start character, as required e.g.
    static boolean
    isNMToken(byte[] value)
    Checks if the specified token is a valid NMToken.
    static boolean
    isQName(byte[] value)
    Checks if the specified token is a valid QName.
    static boolean
    isStartChar(int ch)
    Checks if the specified character is an XML first-letter.
    static boolean
    valid(int ch)
    Checks if the specified character is a valid XML 1.0 character.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • valid

      public static boolean valid(int ch)
      Checks if the specified character is a valid XML 1.0 character.
      Parameters:
      ch - the letter to be checked
      Returns:
      result of check
    • isNCStartChar

      public static boolean isNCStartChar(int ch)
      Checks if the specified character is a name start character, as required e.g. by QName and NCName.
      Parameters:
      ch - character
      Returns:
      result of check
    • isNCChar

      public static boolean isNCChar(int ch)
      Checks if the specified character is an XML letter.
      Parameters:
      ch - character
      Returns:
      result of check
    • isStartChar

      public static boolean isStartChar(int ch)
      Checks if the specified character is an XML first-letter.
      Parameters:
      ch - the letter to be checked
      Returns:
      result of check
    • isChar

      public static boolean isChar(int ch)
      Checks if the specified character is an XML letter.
      Parameters:
      ch - the letter to be checked
      Returns:
      result of check
    • isNCName

      public static boolean isNCName(byte[] value)
      Checks if the specified token is a valid NCName.
      Parameters:
      value - value to be checked
      Returns:
      result of check
    • isName

      public static boolean isName(byte[] value)
      Checks if the specified token is a valid name.
      Parameters:
      value - value to be checked
      Returns:
      result of check
    • isNMToken

      public static boolean isNMToken(byte[] value)
      Checks if the specified token is a valid NMToken.
      Parameters:
      value - value to be checked
      Returns:
      result of check
    • isQName

      public static boolean isQName(byte[] value)
      Checks if the specified token is a valid QName.
      Parameters:
      value - value to be checked
      Returns:
      result of check
    • isId

      public static boolean isId(byte[] name, boolean idref)
      Checks if the specified name is an id/idref attribute (idref: local name must contain 'idref'; id: local name must contain 'if', but not 'idref'). The correct approach would be to gather all id/idref attributes and store them as meta data.
      Parameters:
      name - name
      idref - id/idref flag
      Returns:
      result of check
    • encode

      public static byte[] encode(byte[] name, boolean lax)
      Encodes a string to a valid NCName.
      Parameters:
      name - token to be encoded
      lax - lax encoding (lossy, but better readable)
      Returns:
      valid NCName
    • decode

      public static byte[] decode(byte[] name, boolean lax)
      Decodes an NCName to a string.
      Parameters:
      name - name
      lax - lax decoding
      Returns:
      cached QName, or null if not successful
    • getEntity

      public static byte[] getEntity(byte[] key)
      Returns the unicode for the specified entity or null.
      Parameters:
      key - key
      Returns:
      unicode