Package org.exist.util.serializer

Examples of org.exist.util.serializer.AttrList


            e.printStackTrace();
        }
    }

    public synchronized void groupStart(Group group) {
        AttrList attribs = new AttrList();
        attribs.addAttribute(NAME_ATTRIB, group.getName());
        try {
            serializer.startElement(GROUP_ELEMENT, attribs);
        } catch (SAXException e) {
            e.printStackTrace();
        }
View Full Code Here


                            nsdecls = reader.getNamespaceCount();
                            for( int ni = 0; ni < nsdecls; ni++ ) {
                                receiver.startPrefixMapping( reader.getNamespacePrefix( ni ), reader.getNamespaceURI( ni ) );
                            }

                            final AttrList attribs = new AttrList();
                            for( int j = 0; j < reader.getAttributeCount(); j++ ) {
                                final QName qn = new QName( reader.getAttributeLocalName( j ), reader.getAttributeNamespace( j ), reader.getAttributePrefix( j ) );
                                attribs.addAttribute( qn, reader.getAttributeValue( j ) );
                            }
                            receiver.startElement( new QName( reader.getLocalName(), reader.getNamespaceURI(), reader.getPrefix() ), attribs );
                            break;
                        }
View Full Code Here

    private void readAttributes() {
        if (attributes == null) {
            final ElementEvent parent = elementStack.peek();
            final int count = getAttributeCount();
            attributes = new AttrList();
            for (int i = 0; i < count; i++) {
                final Value v = iterator.next();
                AttrImpl.addToList(broker, v.data(), v.start(), v.getLength(), attributes);
                parent.incrementChild();
            }
View Full Code Here

            setStylesheetFromProperties(null);
        } catch (final TransformerConfigurationException e) {
            throw new SAXException(e.getMessage(), e);
        }
        setXSLHandler(null, false);
    final AttrList attrs = new AttrList();
    attrs.addAttribute(ATTR_HITS_QNAME, Integer.toString(seq.getItemCount()));
    attrs.addAttribute(ATTR_START_QNAME, Integer.toString(start));
    attrs.addAttribute(ATTR_COUNT_QNAME, Integer.toString(count));
    if (outputProperties.getProperty(PROPERTY_SESSION_ID) != null) {
            attrs.addAttribute(ATTR_SESSION_ID, outputProperties.getProperty(PROPERTY_SESSION_ID));
        }
    receiver.startDocument();
    if(wrap) {
      receiver.startPrefixMapping("exist", Namespaces.EXIST_NS);
      receiver.startElement(ELEM_RESULT_QNAME, attrs);
View Full Code Here

            } catch (final TransformerConfigurationException e) {
                throw new SAXException(e.getMessage(), e);
            }
           
            setXSLHandler(null, false);
            final AttrList attrs = new AttrList();
            attrs.addAttribute(ATTR_HITS_QNAME, "1");
            attrs.addAttribute(ATTR_START_QNAME, "1");
            attrs.addAttribute(ATTR_COUNT_QNAME, "1");
            if (outputProperties.getProperty(PROPERTY_SESSION_ID) != null) {
                attrs.addAttribute(ATTR_SESSION_ID, outputProperties.getProperty(PROPERTY_SESSION_ID));
            }
   
            receiver.startDocument();
           
            if(wrap) {
View Full Code Here

                } else {
                    serializeToReceiver(node, false);
                }
            } else {
                if(wrap) {
                        attrs = new AttrList();
                        attrs.addAttribute(ATTR_TYPE_QNAME, Type.getTypeName(item.getType()));
                        receiver.startElement(ELEM_VALUE_QNAME, attrs);
                }
                try {
                        receiver.characters(item.getStringValue());
View Full Code Here

     * @param item a NodeValue which will be wrapped in a element.
     * @throws SAXException
     * @author Charles Foster
     */
    protected void serializeTypePreNode(NodeValue item) throws SAXException {
        AttrList attrs = null;

        switch(item.getType()) {
            case Type.DOCUMENT:

                final String baseUri = item.getOwnerDocument().getBaseURI();

                attrs = new AttrList();
                if(baseUri != null && baseUri.length() > 0){
                    attrs.addAttribute(ATTR_URI_QNAME, baseUri);
                }
                if(item.getOwnerDocument().getDocumentElement() == null) {
                    attrs.addAttribute(ATTR_HAS_ELEMENT_QNAME, "false");
                }

                receiver.startElement(ELEM_DOC_QNAME, attrs);
                break;

            case Type.ATTRIBUTE:
                attrs = new AttrList();

                String attributeValue;
                if((attributeValue = item.getNode().getLocalName()) != null && attributeValue.length() > 0){
                    attrs.addAttribute(ATTR_LOCAL_QNAME, attributeValue);
                }
                if((attributeValue = item.getNode().getNamespaceURI()) != null && attributeValue.length() > 0) {
                    attrs.addAttribute(ATTR_TNS_QNAME, attributeValue);
                }
                if((attributeValue = item.getNode().getPrefix()) != null && attributeValue.length() > 0) {
                    attrs.addAttribute(ATTR_PREFIX_QNAME, attributeValue);
                }

                receiver.startElement(ELEM_ATTR_QNAME, attrs);
                break;

View Full Code Here

            }
          }
          final String ns = defaultNS == null ? node.getNamespaceURI() : defaultNS;
          if (ns.length() > 0 && (!namespaces.contains(ns)))
            {receiver.startPrefixMapping(node.getPrefix(), ns);}
          final AttrList attribs = new AttrList();
          if ((first && showId == EXIST_ID_ELEMENT) || showId == EXIST_ID_ALL) {
                attribs.addAttribute(ID_ATTRIB, node.getNodeId().toString());
            /*
             * This is a proposed fix-up that the serializer could do
             * to make sure elements always have the namespace declarations
             *
            } else {
               // This is fix-up for when the node has a namespace but there is no
               // namespace declaration.
               String elementNS = node.getNamespaceURI();
               Node parent = node.getParentNode();
               if (parent instanceof ElementImpl) {
                  ElementImpl parentElement = (ElementImpl)parent;
                  String declaredNS = parentElement.getNamespaceForPrefix(node.getPrefix());
                  if (elementNS!=null && declaredNS==null) {
                     // We need to declare the prefix as it was missed somehow
                     receiver.startPrefixMapping(node.getPrefix(), elementNS);
                  } else if (elementNS==null && declaredNS!=null) {
                     // We need to declare the default namespace to be the no namespace
                     receiver.startPrefixMapping(node.getPrefix(), elementNS);
                  } else if (!elementNS.equals(defaultNS)) {
                     // Same prefix but different namespace
                     receiver.startPrefixMapping(node.getPrefix(), elementNS);
                  }
               } else if (elementNS!=null) {
                  // If the parent is the document, we must have a namespace
                  // declaration when there is a namespace URI.
                  receiver.startPrefixMapping(node.getPrefix(), elementNS);
               }
             */
            }
            if (first && showId > 0) {
              // String src = doc.getCollection().getName() + "/" + doc.getFileName();
                attribs.addAttribute(SOURCE_ATTRIB, doc.getFileURI().toString());
            }
            final int children = node.getChildCount();
            int count = 0;
            // int childLen;
            StoredNode child = null;
            while (count < children) {
                child = (StoredNode) iter.next();
                if (child!=null && child.getNodeType() == Node.ATTRIBUTE_NODE) {
                    if ((getHighlightingMode() & TAG_ATTRIBUTE_MATCHES) > 0)
                        {cdata = processAttribute(((AttrImpl) child).getValue(), node.getNodeId(), match);}
                    else
                        {cdata = ((AttrImpl) child).getValue();}
                    attribs.addAttribute(child.getQName(), cdata);
                    count++;
                    child.release();
                } else
                    {break;}
            }
            receiver.setCurrentNode(node);
            receiver.startElement(node.getQName(), attribs);
            while (count < children) {
                serializeToReceiver(child, iter, doc, false, match, namespaces);
                if (++count < children) {
                    child = (StoredNode) iter.next();
                } else
                    {break;}
            }
            receiver.setCurrentNode(node);
            receiver.endElement(node.getQName());
            if (((ElementImpl) node).declaresNamespacePrefixes()) {
                String prefix;
                for (final Iterator<String> i = ((ElementImpl) node).getPrefixes(); i.hasNext();) {
                    prefix = i.next();
                    receiver.endPrefixMapping(prefix);
                }
            }
            if (ns.length() > 0 && (!namespaces.contains(ns)))
                {receiver.endPrefixMapping(node.getPrefix());}
            node.release();
            break;
        case Node.TEXT_NODE:
          if (first && createContainerElements) {
                final AttrList tattribs = new AttrList();
                if (showId > 0) {
                    tattribs.addAttribute(ID_ATTRIB, node.getNodeId().toString());
                    tattribs.addAttribute(SOURCE_ATTRIB, doc.getFileURI().toString());
                }
                receiver.startElement(TEXT_ELEMENT, tattribs);
            }
            receiver.setCurrentNode(node);
            receiver.characters(((TextImpl) node).getXMLString());
            if (first && createContainerElements)
                {receiver.endElement(TEXT_ELEMENT);}
            node.release();
            break;
        case Node.ATTRIBUTE_NODE:
            if ((getHighlightingMode() & TAG_ATTRIBUTE_MATCHES) == TAG_ATTRIBUTE_MATCHES)
                {cdata = processAttribute(((AttrImpl) node).getValue(), node.getNodeId(), match);}
            else
                {cdata = ((AttrImpl) node).getValue();}
          if(first) {
                if (createContainerElements) {              
                final AttrList tattribs = new AttrList();
                    if (showId > 0) {
                        tattribs.addAttribute(ID_ATTRIB, node.getNodeId().toString());
                        tattribs.addAttribute(SOURCE_ATTRIB, doc.getFileURI().toString());
                    }
                    tattribs.addAttribute(node.getQName(), cdata);
                    receiver.startElement(ATTRIB_ELEMENT, tattribs);
                    receiver.endElement(ATTRIB_ELEMENT);
                }
                else {
                  if (this.outputProperties.getProperty("output-method") != null &&
View Full Code Here

TOP

Related Classes of org.exist.util.serializer.AttrList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.