com.spss.psapi.content

Interface XMLContentModel

  • All Superinterfaces:
    ContentModel


    public interface XMLContentModel
    extends ContentModel
    An interface that provides a mechanism for accessing the XML content of a ContentContainer. Content is accessed using XPath syntax without having to configure the additional parsers although callers can access the underlying XML text if they prefer to use a different mechanism.
    Since:
    PSAPI 17.0
    See Also:
    ContentContainer
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.lang.Boolean getBooleanValue(java.lang.String xpath)
      Returns the boolean result of evaluating the specified path expression.
      java.lang.Number getNumericValue(java.lang.String xpath)
      Returns the result of evaluating the path with return type of numeric e.g. count the number of elements that match the path expression.
      java.lang.String getStringValue(java.lang.String xpath, java.lang.String attribute)
      Evaluates the XPath expression to an XML node and returns either the value of the specified attribute in that node if the attribute name is a non-zero length string or the node value otherwise.
      java.util.List<java.lang.String> getStringValues(java.lang.String xpath, java.lang.String attribute)
      Evaluates the XPath expression to a collection of XML nodes and returns a list containing either the value of the specified attribute in that node if the attribute name is a non-zero length string or the node value otherwise.
      java.util.List<java.util.List<java.lang.String>> getValuesList(java.lang.String xpath, java.util.List<java.lang.String> attributes, boolean includeValue)
      Evaluates the XPath expression to obtain a list of XML nodes and returns a list of lists where each sublist contains the specified values from a particular node.
      java.util.Map<java.lang.String,java.util.List<java.lang.String>> getValuesMap(java.lang.String xpath, java.lang.String keyAttribute, java.util.List<java.lang.String> attributes, boolean includeValue)
      Evaluates the XPath expression to obtain a list of XML nodes and returns a hash table of the specified attributes.
      java.lang.String getXMLAsString()
      Returns the XML as a string.
      boolean isNamespaceAware()
      Returns true if the content model is aware of XML namespaces when parsing XML documents.
      void setNamespaceAware(boolean isAware)
      Sets whether the content model is aware of XML namespaces when parsing XML documents.
    • Method Detail

      • getNumericValue

        java.lang.Number getNumericValue(java.lang.String xpath)
                                         throws java.lang.Exception
        Returns the result of evaluating the path with return type of numeric e.g. count the number of elements that match the path expression.
        Parameters:
        xpath - the XPath expression
        Returns:
        the result of evaluating the expression
        Throws:
        java.lang.Exception
      • getBooleanValue

        java.lang.Boolean getBooleanValue(java.lang.String xpath)
                                          throws java.lang.Exception
        Returns the boolean result of evaluating the specified path expression.
        Parameters:
        xpath - the XPath expression
        Returns:
        the result of evaluating the expression
        Throws:
        java.lang.Exception
      • getStringValue

        java.lang.String getStringValue(java.lang.String xpath,
                                      java.lang.String attribute)
                                        throws java.lang.Exception
        Evaluates the XPath expression to an XML node and returns either the value of the specified attribute in that node if the attribute name is a non-zero length string or the node value otherwise.
        Parameters:
        xpath - the XPath expression
        attribute - the name of the attribute to be returned or null if the XML node value is to be returned
        Returns:
        the result of evaluating the expression
        Throws:
        java.lang.Exception
      • getStringValues

        java.util.List<java.lang.String> getStringValues(java.lang.String xpath,
                                                       java.lang.String attribute)
                                                         throws java.lang.Exception
        Evaluates the XPath expression to a collection of XML nodes and returns a list containing either the value of the specified attribute in that node if the attribute name is a non-zero length string or the node value otherwise.
        Parameters:
        xpath - the XPath expression
        attribute - the name of the attribute to be returned or null if the XML node value is to be returned
        Returns:
        a list of matching values
        Throws:
        java.lang.Exception
      • getValuesList

        java.util.List<java.util.List<java.lang.String>> getValuesList(java.lang.String xpath,
                                                                     java.util.List<java.lang.String> attributes,
                                                                     boolean includeValue)
                                                                       throws java.lang.Exception
        Evaluates the XPath expression to obtain a list of XML nodes and returns a list of lists where each sublist contains the specified values from a particular node. The values of the named attributes are added to each sublist and the node value is added to the end of the sublist if the includeValue flag is set to true.
        Parameters:
        xpath - the XPath expression
        attributes - the list of attribute names whose values are to be returned in each sublist
        includeValue - whether the XML node value should be included at the end of each sublist
        Returns:
        a list of lists of string representing the specified attribute values
        Throws:
        java.lang.Exception
      • getValuesMap

        java.util.Map<java.lang.String,java.util.List<java.lang.String>> getValuesMap(java.lang.String xpath,
                                                                                    java.lang.String keyAttribute,
                                                                                    java.util.List<java.lang.String> attributes,
                                                                                    boolean includeValue)
                                                                                      throws java.lang.Exception
        Evaluates the XPath expression to obtain a list of XML nodes and returns a hash table of the specified attributes. The key for each entry is either the value of the specified key attribute in that node if the key attribute name is a non-zero length string or the node value otherwise. The value for each entry in the table is a list containing the specified values from the key node. The node value is added to the end of each list if the includeValue flag is set to true.
        Parameters:
        xpath - the XPath expression
        keyAttribute -
        attributes - the list of attribute names whose values are to be returned in each table entry list
        includeValue - whether the XML node value should be included at the end of each table entry list
        Returns:
        a map containing the specified attribute values
        Throws:
        java.lang.Exception
      • getXMLAsString

        java.lang.String getXMLAsString()
        Returns the XML as a string.
        Returns:
        a string containing the XML
      • isNamespaceAware

        boolean isNamespaceAware()
        Returns true if the content model is aware of XML namespaces when parsing XML documents. The default value is false.
        Returns:
        true if the content model is aware of XML namespaces
      • setNamespaceAware

        void setNamespaceAware(boolean isAware)
        Sets whether the content model is aware of XML namespaces when parsing XML documents. Moidyfing this value can affect the syntax that should be used in XPath expressions. By default, XML content models are not namespace aware. When the value is changed, reset() is called to ensure that all internal storage is flushed to ensure any documents are re-parsed with the new setting.
        Parameters:
        isAware - whether the content model should be namespace aware
        See Also:
        ContentModel.reset()

(C) Copyright IBM Corp. 1994, 2015. All Rights Reserved.