Class Xsd10Schemas

java.lang.Object
org.libxmq.imp.xml.xsd10.Xsd10Schemas

public final class Xsd10Schemas extends Object
Port of xml_xsd10_schemas.c: helpers, error reporting, allocation, the context lifecycle, the dict and hash tables and the public setters.
  • Field Details

    • GENERIC_ERROR

      public static final Xsd10Const.ValidityErrorFunc GENERIC_ERROR
      The function xml_xsd10_generic_error as a ValidityErrorFunc. vRaiseError compares the channel with this instance (C compares the function pointer), so pass this one, not a new method reference.
    • GENERIC_WARNING

      public static final Xsd10Const.ValidityWarningFunc GENERIC_WARNING
      The function xml_xsd10_generic_error as a ValidityWarningFunc (C casts the warning function to the error function type; a warning channel equal to this one is the generic error channel).
  • Method Details

    • format

      public static String format(String fmt, Object... args)
      A C (glibc) printf for the messages of the xsd 1.0 port, usable by all its parts. Supports the flags - + space # 0, a width and a precision (digits or *), the length modifiers hh h l ll z j t L q (ignored, the Java argument type decides) and the conversions d i u o x X c s p e E f F g G %. Arguments: Integer/Long/Short/Byte (an Integer is a C int, so %u/%x of a negative Integer prints its 32 bit unsigned value, a Long its 64 bit unsigned value), Boolean (1/0), Character, Double/Float, String (null prints "(null)" like glibc, or "" if the precision is below 6), any Object for %p ("(nil)" for null). Width and precision of %s count UTF-8 bytes like C. Missing arguments are taken as null/0.
      Parameters:
      fmt - the C format
      args - the arguments
      Returns:
      the formatted text
    • genericError

      public static void genericError(Object ctx, String msg, Object... args)
      Port of xml_xsd10_generic_error: printf to stderr.
      Parameters:
      ctx - unused
      msg - format
      args - arguments
    • formatError

      public static void formatError(Xsd10Error err, Xsd10Const.ValidityErrorFunc channel, Object data)
      Port of xml_xsd10_format_error (libxml2 xmlFormatError).
      Parameters:
      err - the error
      channel - where to print
      data - the channel data
    • formatErrorString

      public static String formatErrorString(Xsd10Error err)
      Port of xml_xsd10_format_error_string: formatError into a string.
      Parameters:
      err - the error
      Returns:
      the text ("" if nothing)
    • defaultLoader

      public static XmlDocument defaultLoader(Object user_data, String uri)
      Port of xml_xsd10_default_loader: read and parse the file uri, problems go to stderr.
      Parameters:
      user_data - unused
      uri - the uri or path
      Returns:
      the document or null
    • free

      public static void free(Xsd10Schema schema)
      Port of xmlSchemaFree: deallocate a Schema structure.
      Parameters:
      schema - a schema structure
    • newParserCtxt

      public static Xsd10ParserCtxt newParserCtxt(String URL)
      Port of xmlSchemaNewParserCtxt: create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file.
      Parameters:
      URL - the location of the schema
      Returns:
      the parser context or null in case of error
    • newMemParserCtxt

      public static Xsd10ParserCtxt newMemParserCtxt(String buffer, int size)
      Port of xmlSchemaNewMemParserCtxt: create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file.
      Parameters:
      buffer - the schema text
      size - its size (in UTF-8 bytes)
      Returns:
      the parser context or null in case of error
    • newDocParserCtxt

      public static Xsd10ParserCtxt newDocParserCtxt(XmlDocument doc)
      Port of xmlSchemaNewDocParserCtxt: create an XML Schemas parse context for that document. NB. The document may be modified during the parsing process.
      Parameters:
      doc - a preparsed document tree
      Returns:
      the parser context or null in case of error
    • freeParserCtxt

      public static void freeParserCtxt(Xsd10ParserCtxt ctxt)
      Port of xmlSchemaFreeParserCtxt: free the resources associated to the schema parser context.
      Parameters:
      ctxt - the schema parser context
    • setParserErrors

      public static void setParserErrors(Xsd10ParserCtxt ctxt, Xsd10Const.ValidityErrorFunc err, Xsd10Const.ValidityWarningFunc warn, Object ctx)
      Port of xmlSchemaSetParserErrors: set the callback functions used to handle errors for a validation context.
      Parameters:
      ctxt - a schema validation context
      err - the error callback
      warn - the warning callback
      ctx - contextual data for the callbacks
    • setParserStructuredErrors

      public static void setParserStructuredErrors(Xsd10ParserCtxt ctxt, Xsd10Const.StructuredErrorFunc serror, Object ctx)
      Port of xmlSchemaSetParserStructuredErrors: set the structured error callback.
      Parameters:
      ctxt - a schema parser context
      serror - the structured error function
      ctx - the functions context
    • getParserErrors

      public static int getParserErrors(Xsd10ParserCtxt ctxt, Xsd10Const.ValidityErrorFunc[] err, Xsd10Const.ValidityWarningFunc[] warn, Object[] ctx)
      Port of xmlSchemaGetParserErrors: get the callback information used to handle errors for a parser context.
      Parameters:
      ctxt - a XMl-Schema parser context
      err - the error callback result
      warn - the warning callback result
      ctx - contextual data for the callbacks result
      Returns:
      -1 in case of failure, 0 otherwise
    • setResourceLoader

      public static void setResourceLoader(Xsd10ParserCtxt ctxt, Xsd10Const.Loader loader, Object data)
      Port of xmlSchemaSetResourceLoader: register a callback function that will be called to load documents or external entities.
      Parameters:
      ctxt - schema parser
      loader - resource loader
      data - user data which will be passed to the loader
    • isValid

      public static int isValid(Xsd10ValidCtxt ctxt)
      Port of xmlSchemaIsValid: check if any error was detected during validation.
      Parameters:
      ctxt - the schema validation context
      Returns:
      1 if valid so far, 0 if errors were detected, and -1 in case of internal error
    • setValidErrors

      public static void setValidErrors(Xsd10ValidCtxt ctxt, Xsd10Const.ValidityErrorFunc err, Xsd10Const.ValidityWarningFunc warn, Object ctx)
      Port of xmlSchemaSetValidErrors: set the error and warning callback information.
      Parameters:
      ctxt - a schema validation context
      err - the error function
      warn - the warning function
      ctx - the functions context
    • setValidStructuredErrors

      public static void setValidStructuredErrors(Xsd10ValidCtxt ctxt, Xsd10Const.StructuredErrorFunc serror, Object ctx)
      Port of xmlSchemaSetValidStructuredErrors: set the structured error callback.
      Parameters:
      ctxt - a schema validation context
      serror - the structured error function
      ctx - the functions context
    • getValidErrors

      public static int getValidErrors(Xsd10ValidCtxt ctxt, Xsd10Const.ValidityErrorFunc[] err, Xsd10Const.ValidityWarningFunc[] warn, Object[] ctx)
      Port of xmlSchemaGetValidErrors: get the error and warning callback information.
      Parameters:
      ctxt - a XML-Schema validation context
      err - the error function result
      warn - the warning function result
      ctx - the functions context result
      Returns:
      -1 in case of error and 0 otherwise
    • setValidOptions

      public static int setValidOptions(Xsd10ValidCtxt ctxt, int options)
      Port of xmlSchemaSetValidOptions: sets the options to be used during the validation.
      Parameters:
      ctxt - a schema validation context
      options - a combination of xmlSchemaValidOption
      Returns:
      0 in case of success, -1 in case of an API error
    • validCtxtGetOptions

      public static int validCtxtGetOptions(Xsd10ValidCtxt ctxt)
      Port of xmlSchemaValidCtxtGetOptions: get the validation context options.
      Parameters:
      ctxt - a schema validation context
      Returns:
      the option combination or -1 on error