Logo Search packages:      
Sourcecode: jing-trang version File versions  Download package

boolean com::thaiopensource::validate::nvdl::ValidatorImpl::processAttributes ( Attributes  attributes  )  throws SAXException [inline, private]

Processes the element attributes.

attributes The element attributes
true if we need to filter attributes when we pass them to the active handlers, false if we can just pass the initial attributes to all the active content handlers

Definition at line 488 of file ValidatorImpl.java.

References activeHandlersAttributeIndexSets, com::thaiopensource::validate::nvdl::ValidatorImpl::Section::activeHandlersAttributeModeUsage, com::thaiopensource::validate::nvdl::IntSet::add(), attributeNamespaceIndexSets, attributeNamespaceRejected, com::thaiopensource::validate::nvdl::ValidatorImpl::Section::attributeProcessing, attributeSchemas, com::thaiopensource::validate::nvdl::ValidatorImpl::Section::attributeValidationModeUsages, com::thaiopensource::validate::nvdl::Hashset::clear(), currentSection, filteredAttributes, com::thaiopensource::validate::nvdl::AttributeActionSet::getAttach(), and processAttributeSection().

Referenced by startElement().

    // if no match on attributes or no attributes -> no need to filter them.
    if (currentSection.attributeProcessing == Mode.ATTRIBUTE_PROCESSING_NONE
        || attributes.getLength() == 0)
      return false;
    // clear the attributeNamespaceIndexSets hashtable.
    // creates index sets based on namespace for the attributes
    // and places them in the attributeNamespaceIndexSets hashtable 
    for (int i = 0, len = attributes.getLength(); i < len; i++) {
      String ns = attributes.getURI(i);
      IntSet indexSet = (IntSet)attributeNamespaceIndexSets.get(ns);
      if (indexSet == null) {
        indexSet = new IntSet();
        attributeNamespaceIndexSets.put(ns, indexSet);
    // if we need to process only qualified attributes and we have attributes 
    // only in no namespace then return false, no need to filter the attributes
    if (currentSection.attributeProcessing == Mode.ATTRIBUTE_PROCESSING_QUALIFIED
        && attributeNamespaceIndexSets.size() == 1
        && attributeNamespaceIndexSets.get("") != null)
      return false;
    // Computes the index sets for each handler
    // get the attribute modes for handlers
    Vector handlerModes = currentSection.activeHandlersAttributeModeUsage;
    // resize the index set list to the number of handlers
    // creates empty index sets for all handlers - initialization
    for (int i = 0, len = handlerModes.size(); i < len; i++)
      activeHandlersAttributeIndexSets.setElementAt(new IntSet(), i);
    // we hope we will not need attribute filtering, so we start with transform false.
    boolean transform = false;
    // get the list of attribute validation mode usages
    Vector validationModes = currentSection.attributeValidationModeUsages;
    // iterate on all attribute namespaces
    for (Enumeration e = attributeNamespaceIndexSets.keys(); e.hasMoreElements();) {
      String ns = (String)e.nextElement();
      // get the index set that represent the attributes in the ns namespace
      IntSet indexSet = (IntSet)attributeNamespaceIndexSets.get(ns);
      // clear attribute schemas for this namespace
      // it is used to avoid validating twice the set of attributes 
      // from this namespace with the same schema.
      // set the filetered attributes to null - we use this to compute
      // only one the filtered attributes for this namespace, laysily when we 
      // will need them for the first time.
      filteredAttributes = null;
      // flag indicating if we had a reject action on attributes from this namespace
      // we initialize it here in the iteration on attribute namespaces
      attributeNamespaceRejected = false;
      // iterates all the handler modes and compute the index sets for all handlers
      for (int i = 0, len = handlerModes.size(); i < len; i++) {
        ModeUsage modeUsage = (ModeUsage)handlerModes.elementAt(i);
        // get the attribute actions for this mode usage, ns namespace 
        // and for the attributes in this namespace
        AttributeActionSet actions = processAttributeSection(modeUsage, ns, indexSet, attributes);
        // if we need to attach the attributes we mark that they should be passed
        // to the handler by adding them to the index set for the handler
        if (actions.getAttach())
        // if that attributes are not attached then we set the transform flag to 
        // true as that means we need to filter out these attributes for the current handler
          transform = true;
      // iterate the attribute validation mode usages
      // and process the attribute section with the attributes
      // from the current namespace
      for (int i = 0, len = validationModes.size(); i < len; i++) {
        ModeUsage modeUsage = (ModeUsage)validationModes.elementAt(i);
        // validation means no result actions, so we are not 
        // interested in the attribute action set returned by
        // the processAttributeSection method
        processAttributeSection(modeUsage, ns, indexSet, attributes);
    return transform;

Generated by  Doxygen 1.6.0   Back to index