Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.AttributesImpl


   */
  protected AttributesImpl addNamespaceAttribute(AttributesImpl attrs,
                                                 Namespace namespace) {
    if (declareNamespaceAttributes) {
      if (attrs == null) {
        attrs = new AttributesImpl();
      }

      String prefix = namespace.getPrefix();
      String qualifiedName = "xmlns";

View Full Code Here


     *
     */
    private Attributes extractNamespaces( Attributes attrs )
    throws SAXException
    {
        AttributesImpl attrsOnly;
        String         rawName;
        int            i;
        int            indexColon;
        String         prefix;
        int            length;

        if (attrs == null) {
            return null;
        }
        length = attrs.getLength();
        attrsOnly = new AttributesImpl( attrs );

        for (i = length - 1 ; i >= 0 ; --i) {
            rawName = attrsOnly.getQName( i );

            //We have to exclude the namespaces declarations from the attributes
            //Append only when the feature http://xml.org/sax/features/namespace-prefixes"
            //is TRUE
            if (rawName.startsWith( "xmlns" )) {
                if (rawName.length() == 5) {
                    startPrefixMapping( "", attrs.getValue( i ) );
                    attrsOnly.removeAttribute( i );
                } else if (rawName.charAt(5) == ':') {
                    startPrefixMapping(rawName.substring(6), attrs.getValue(i));
                    attrsOnly.removeAttribute( i );
                }
            }
        }
        return attrsOnly;
    }
View Full Code Here

     * Get the attributes associated with the given START_ELEMENT StAXevent.
     *
     * @return the StAX attributes converted to an org.xml.sax.Attributes
     */
    private Attributes getAttributes(StartElement event) {
        AttributesImpl attrs = new AttributesImpl();

        if ( !event.isStartElement() ) {
            throw new InternalError(
                "getAttributes() attempting to process: " + event);
        }
       
        // in SAX, namespace declarations are not part of attributes by default.
        // (there's a property to control that, but as far as we are concerned
        // we don't use it.) So don't add xmlns:* to attributes.

        // gather non-namespace attrs
        for (Iterator i = event.getAttributes(); i.hasNext();) {
            Attribute staxAttr = (javax.xml.stream.events.Attribute)i.next();
           
            String uri = staxAttr.getName().getNamespaceURI();
            if (uri == null) {
                uri = "";
            }
            String localName = staxAttr.getName().getLocalPart();
            String prefix = staxAttr.getName().getPrefix();
            String qName;
            if (prefix == null || prefix.length() == 0) {
                qName = localName;
            } else {
                qName = prefix + ':' + localName;
            }
            String type = staxAttr.getDTDType();
            String value = staxAttr.getValue();
           
            attrs.addAttribute(uri, localName, qName, type, value);
        }

        return attrs;
    }
View Full Code Here

      locator.setColumnNumber(1);

      this.parser.setDocumentLocator(locator);
      this.parser.startDocument();
      this.parser.startElement("http://chaperon.sourceforge.net/schema/text/1.0", "text", "text",
                               new AttributesImpl());

      LineNumberReader reader =
        new LineNumberReader(new InputStreamReader(new FileInputStream(inFile)));

      String line;
View Full Code Here

          break;

        case SAXEvent.START_ELEMENT:

          AttributesImpl attributes = new AttributesImpl();
          List attParmList = (List) saxEvent.getParm(3);

          if (attParmList != null) {
            Iterator attsItr = attParmList.iterator();

            while (attsItr.hasNext()) {
              String[] attParms = (String[]) attsItr.next();
              attributes.addAttribute(attParms[0], attParms[1],
                  attParms[2], attParms[3], attParms[4]);
            }
          }

          handler.startElement((String) saxEvent.getParm(0),
View Full Code Here

    protected void exportProject(ExportState state, TransformerHandler handler)
            throws SAXException, ExportException {
        DateFormat df = java.text.DateFormat.getDateTimeInstance(
                DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.getDefault());
        handler.startDocument();
        AttributesImpl attrs = new AttributesImpl();
        addAttribute("xmlns:xsl", "http://www.w3.org/1999/XSL/Transform", attrs);
        addAttribute("xmlns:ganttproject", "http://ganttproject.sf.net/", attrs);
        addAttribute("version", "1.0", attrs);
        startElement("xsl:stylesheet", attrs, handler);
        // handler.startPrefixMapping("ganttproject",
View Full Code Here

      return "\n\r";
    }

  private void writeCharts(ExportState state, TransformerHandler handler)
            throws SAXException {
        AttributesImpl attrs = new AttributesImpl();
        addAttribute("title", i18n("ganttChart"), attrs);
        addAttribute("src", state.ganttChartImageFile.getAbsolutePath(), attrs);
        startPrefixedElement("ganttchart", attrs, handler);
        endPrefixedElement("ganttchart", handler);
View Full Code Here

        return result;
    }

    private void createConfiguration(TransformerHandler handler,
            FontRecord[] fontRecords) throws SAXException, UnsupportedEncodingException {
        AttributesImpl attrs = new AttributesImpl();
        handler.startDocument();
        handler.startElement("", "configuration", "configuration", attrs);
        handler.startElement("", "fonts", "fonts", attrs);

        for (int i = 0; i < fontRecords.length; i++) {
            FontRecord nextRecord = fontRecords[i];
            attrs.clear();
            String metricsFile = URLDecoder.decode(nextRecord.getMetricsLocation().toString(), "utf-8");
            attrs.addAttribute("", "metrics-file", "metrics-file", "CDATA", metricsFile);
            attrs.addAttribute("", "kerning", "kerning", "CDATA", "yes");
            attrs.addAttribute("", "embed-file", "embed-file", "CDATA",
                    nextRecord.getFontLocation().getPath());
            handler.startElement("", "font", "font", attrs);
            writeTriplets(handler, nextRecord.getFontTriplets());
            handler.endElement("", "font", "font");
        }
View Full Code Here

        handler.endDocument();
    }

    private void writeTriplets(TransformerHandler handler,
            FontTriplet[] fontTriplets) throws SAXException {
        AttributesImpl attrs = new AttributesImpl();
        for (int i = 0; i < fontTriplets.length; i++) {
            FontTriplet next = fontTriplets[i];
            attrs.clear();
            attrs.addAttribute("", "name", "name", "CDATA", next.getName());
            attrs.addAttribute("", "style", "style", "CDATA", next.isItalic()
                    ? "italic"
                    : "normal");
            attrs.addAttribute("", "weight", "weight", "CDATA", next.isBold()
                    ? "bold"
                    : "normal");
            handler.startElement("", "font-triplet", "font-triplet", attrs);
            handler.endElement("", "font-triplet", "font-triplet");
        }
View Full Code Here

    else if (state==STATE_LEXEMES)
    {
      if ((namespaceURI!=null) && (namespaceURI.equals(NS)) && (localName.equals(LEXEMES)))
      {
        contentHandler.startPrefixMapping("", NS_OUTPUT);
        contentHandler.startElement(NS_OUTPUT, OUTPUT, OUTPUT, new AttributesImpl());

        processEndDocument();

        contentHandler.endElement(NS_OUTPUT, OUTPUT, OUTPUT);
        contentHandler.endPrefixMapping("");
View Full Code Here

TOP

Related Classes of org.xml.sax.helpers.AttributesImpl

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.