Package org.xml.sax

Examples of org.xml.sax.AttributeList


  public void parse(final Reader in) throws SAXException, IOException {
  final Vector attributeNames = new Vector();
  final Vector attributeValues = new Vector();

  final AttributeList attrs = new AttributeList() {
    public int getLength() {
      return attributeNames.size();
    }

    public String getName(final int i) {
View Full Code Here


                             XMLAttrList attrList, int attrListIndex)
        throws Exception {

        // parameters
        String name = fStringPool.toString(element.rawname);
        AttributeList attrs = attrList.getAttributeList(attrListIndex);

        // perform callback
        if (DEBUG_CALLBACKS) {
            String atts = attrs.getLength() > 0 ? "" : " ";
            for (int i = 0; i < attrs.getLength(); i++) {
                atts += " " + attrs.getName(i) + "='" + attrs.getValue(i) + "'";
            }
            System.err.println("startElement(" + name + "," + atts + ")");
        }
        if (fDocumentHandler != null) {
            fDocumentHandler.startElement(name, attrs);
View Full Code Here

                             XMLAttrList attrList, int attrListIndex)
        throws Exception {

        // parameters
        String name = fStringPool.toString(element.rawname);
        AttributeList attrs = attrList.getAttributeList(attrListIndex);

        // perform callback
        if (DEBUG_CALLBACKS) {
            String atts = attrs.getLength() > 0 ? "" : " ";
            for (int i = 0; i < attrs.getLength(); i++) {
                atts += " " + attrs.getName(i) + "='" + attrs.getValue(i) + "'";
            }
            System.err.println("startElement(" + name + "," + atts + ")");
        }
        if (fDocumentHandler != null) {
            fDocumentHandler.startElement(name, attrs);
View Full Code Here

            boolean nsEnabled = false;
            try { nsEnabled = getNamespaces(); }
            catch (SAXException s) {}

            String elementName = fStringPool.toString(elementTypeIndex);
            AttributeList attrList = xmlAttrList.getAttributeList(attrListIndex);
            // Until DOM2 is REC, the DOM2 methods are in XXXImpl
            Element e;
            if (nsEnabled) {
                //System.out.println("createElementNS:"+
                //fStringPool.toString(fStringPool.getURIForQName(elementTypeIndex)));
                e = (ElementImpl)
                    ((DocumentImpl)fDocument).createElementNS(
                        fStringPool.toString(fStringPool.getURIForQName(elementTypeIndex)),
                        fStringPool.toString(elementTypeIndex)
                    );
            } else {
                e = fDocument.createElement(elementName);
            }
            int attrListLength = attrList.getLength();
            for (int i = 0; i < attrListLength; i++) {
                if (nsEnabled) {
                    // REVISTNS:
                    int attName = xmlAttrList.getAttrName(i);
                    /***
                    // createAttributeNS code below has a bug.
                    // Should be interchangeable with setAttributeNS
                    Attr attr =
                    ((DocumentImpl)fDocument).createAttributeNS(
                        fStringPool.toString(fStringPool.getURIForQName(attName)),
                        fStringPool.toString(attName)
                    );
                    attr.setNodeValue(attrList.getValue(i));
                    e.appendChild(attr);
                    /***/
                    // setAttributeNS can't set qualified name or prefix.
                    // Reported to W3C.
                    ((ElementImpl)e).setAttributeNS(
                        fStringPool.toString(fStringPool.getURIForQName(attName)),
                        fStringPool.toString(attName),
                        attrList.getValue(i));
                    /***/
                    //DEBUGGING...
                    //System.out.println("    Attr uri, name, value");
                    //System.out.println("    "+
                    //    fStringPool.toString(fStringPool.getURIForQName(attName))+", "+
                    //    fStringPool.toString(attName)+", "+
                    //    attrList.getValue(i)
                    //);
                } else {
                    String attrName = attrList.getName(i);
                    String attrValue = attrList.getValue(i);
                    e.setAttribute(attrName, attrValue);
                    // REVISIT: Does this also apply to namespace attributes? -Ac
                    if (fDocumentImpl != null && !xmlAttrList.isSpecified(i)) {
                        ((AttrImpl)e.getAttributeNode(attrName)).setSpecified(false);
                    }
View Full Code Here

    public void startElement(int elementType, XMLAttrList attrList, int attrListIndex)
        throws Exception {

        // parameters
        String name = fStringPool.toString(elementType);
        AttributeList attrs = attrList.getAttributeList(attrListIndex);

        // perform callback
        if (DEBUG_CALLBACKS) {
            String atts = attrs.getLength() > 0 ? "" : " ";
            for (int i = 0; i < attrs.getLength(); i++) {
                atts += " " + attrs.getName(i) + "='" + attrs.getValue(i) + "'";
            }
            System.err.println("startElement(" + name + "," + atts + ")");
        }
        if (fDocumentHandler != null) {
            fDocumentHandler.startElement(name, attrs);
View Full Code Here



        String name = element.getNodeName();

        AttributeList atts
            = new AttributeListWrapper(element.getAttributes());

        handler.startElement(name, atts);

        processChildren(element, handler);
View Full Code Here

    // If param is an attrib, set it
    public void start( SaxContext ctx) {
  if( attrib==null) return;
  String h[]=(String[])ctx.currentObject();
  AttributeList attributes = ctx.getCurrentAttributes();
  h[paramId]= attributes.getValue(attrib);
    }
View Full Code Here

  this.valAtt=valueAtt;
  this.reset=reset;
    }
   
    public void start( SaxContext ctx) throws Exception {
  AttributeList attributes = ctx.getCurrentAttributes();
  String n=varName;
  if( n==null )
      n=attributes.getValue( nameAtt );
  String v=attributes.getValue( valAtt );
 
  if( n!=null && v!=null )
      ctx.setVariable( n, v);

  if( ctx.getDebug() > 0 )
View Full Code Here

  ContextPropertySource propS=new ContextPropertySource( cm );
  xh.setPropertySource( propS );
 
  xh.addRule( "Context/Property", new XmlAction() {
    public void start(SaxContext ctx ) throws Exception {
        AttributeList attributes = ctx.getCurrentAttributes();
        String name=attributes.getValue("name");
        String value=attributes.getValue("value");
        if( name==null || value==null ) return;
        XmlMapper xm=ctx.getMapper();
       
        Context context=(Context)ctx.currentObject();
        // replace ${foo} in value
View Full Code Here

  xh.setPropertySource( propS );

        // add the "correct" first-letter-capitalized version
        xh.addRule( "ContextManager/Property", new XmlAction() {
                public void start(SaxContext ctx ) throws Exception {
                    AttributeList attributes = ctx.getCurrentAttributes();
                    String name=attributes.getValue("name");
                    String value=attributes.getValue("value");
                    if( name==null || value==null ) return;
                    XmlMapper xm=ctx.getMapper();

                    ContextManager cm1=(ContextManager)ctx.currentObject();
                    // replace ${foo} in value
                    value=xm.replaceProperties( value );
                    if( cm1.getDebug() > 0 )
                        cm1.log("Setting " + name + "=" + value);
                    cm1.setProperty( name, value );
                }
            });

        // for backward compatibility, keep old version
  xh.addRule( "ContextManager/property", new XmlAction() {
    public void start(SaxContext ctx ) throws Exception {
        AttributeList attributes = ctx.getCurrentAttributes();
        String name=attributes.getValue("name");
        String value=attributes.getValue("value");
        if( name==null || value==null ) return;
        XmlMapper xm=ctx.getMapper();
       
        ContextManager cm1=(ContextManager)ctx.currentObject();
        // replace ${foo} in value
View Full Code Here

TOP

Related Classes of org.xml.sax.AttributeList

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.