Examples of AttributesImpl


Examples of org.xml.sax.helpers.AttributesImpl

    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

Examples of org.xml.sax.helpers.AttributesImpl

        locatorImpl.setColumnNumber(production.columnnumber);
      }

      if ((!flatten) || (parent==null) || (!parent.symbol.equals(production.symbol)))
        contentHandler.startElement(NS_OUTPUT, production.symbol.getName(),
                                    production.symbol.getName(), new AttributesImpl());

      for (int i = 0; i<production.descendants.length; i++)
        fireEvents(production, production.descendants[i]);

      if ((!flatten) || (parent==null) || (!parent.symbol.equals(production.symbol)))
        contentHandler.endElement(NS_OUTPUT, production.symbol.getName(),
                                  production.symbol.getName());
    }
    else
    {
      TokenNode token = (TokenNode)node;

      if (locatorImpl!=null)
      {
        locatorImpl.setLineNumber(token.linenumber);
        locatorImpl.setColumnNumber(token.columnnumber);
      }

      contentHandler.startElement(NS_OUTPUT, token.symbol.getName(), token.symbol.getName(),
                                  new AttributesImpl());
      contentHandler.characters(token.text.toCharArray(), 0, token.text.length());
      contentHandler.endElement(NS_OUTPUT, token.symbol.getName(), token.symbol.getName());
    }
  }
View Full Code Here

Examples of org.xml.sax.helpers.AttributesImpl

      locatorImpl.setColumnNumber(columnNumber);
    }

    contentHandler.startPrefixMapping("", NS_OUTPUT);

    AttributesImpl atts = new AttributesImpl();
    if (localizable)
      atts.addAttribute("", "source", "source", "CDATA", source);

    contentHandler.startElement(NS_OUTPUT, OUTPUT, OUTPUT, new AttributesImpl());

    StringBuffer unrecognized = new StringBuffer();
    while (position<text.length)
    {
      String tokensymbol = null;
      String tokentext = null;

      for (int lexemeindex = automaton.getLexemeCount()-1; lexemeindex>=0; lexemeindex--)
      {
        processor.setPatternAutomaton(automaton.getLexemeDefinition(lexemeindex));

        if ((processor.match(text, position)) &&
            ((tokentext==null) || (processor.getGroup().length()>=tokentext.length())))
        {
          tokensymbol = automaton.getLexemeSymbol(lexemeindex);
          tokentext = processor.getGroup();
        }
      }

      if ((tokentext!=null) && (tokentext.length()==0))
        log.warn("Lexical processor recognized empty lexeme '"+tokensymbol+"'");

      if ((tokentext!=null) && (tokentext.length()>0))
      {
        if (unrecognized.length()>0)
        {
          if (log!=null)
            log.debug("Text was not recognized "+Decoder.toString(unrecognized.toString()));

          atts = new AttributesImpl();
          atts.addAttribute("", "text", "text", "CDATA", unrecognized.toString());
          if (localizable)
          {
            atts.addAttribute("", "line", "line", "CDATA", String.valueOf(lineNumber));
            atts.addAttribute("", "column", "column", "CDATA", String.valueOf(columnNumber));
          }

          contentHandler.startElement(NS_OUTPUT, ERROR, ERROR, atts);
          contentHandler.endElement(NS_OUTPUT, ERROR, ERROR);

          increasePosition(position-unrecognized.length(), unrecognized.length());

          unrecognized = new StringBuffer();
        }

        if (tokensymbol!=null)
        {
          if (log!=null)
            log.debug("Recognize token "+tokensymbol+" with "+Decoder.toString(tokentext));

          if (locatorImpl!=null)
          {
            locatorImpl.setLineNumber(locator.getLineNumber());
            locatorImpl.setColumnNumber(locator.getColumnNumber());
          }

          atts = new AttributesImpl();

          atts.addAttribute("", "symbol", "symbol", "CDATA", tokensymbol);
          atts.addAttribute("", "text", "text", "CDATA", tokentext);
          if (localizable)
          {
            atts.addAttribute("", "line", "line", "CDATA", String.valueOf(lineNumber));
            atts.addAttribute("", "column", "column", "CDATA", String.valueOf(columnNumber));
          }

          contentHandler.startElement(NS_OUTPUT, LEXEME, LEXEME, atts);

          if (grouping)
            for (int i = 1; i<processor.getGroupCount(); i++)
            {
              AttributesImpl groupatts = new AttributesImpl();
              groupatts.addAttribute("", "text", "text", "CDATA", processor.getGroup(i));
              contentHandler.startElement(NS_OUTPUT, GROUP, GROUP, groupatts);
              contentHandler.endElement(NS_OUTPUT, GROUP, GROUP);
            }

          contentHandler.endElement(NS_OUTPUT, LEXEME, LEXEME);
        }
        else if (log!=null)
          log.debug("Ignore lexeme with "+Decoder.toString(tokentext));

        if (locatorImpl!=null)
        {
          locatorImpl.setColumnNumber(columnNumber);
          locatorImpl.setLineNumber(lineNumber);
        }

        position += tokentext.length();

        increasePosition(position-tokentext.length(), tokentext.length());
      }
      else
      {
        if (locatorImpl!=null)
        {
          locatorImpl.setColumnNumber(columnNumber);
          locatorImpl.setLineNumber(lineNumber);
        }

        unrecognized.append(text[position]);
        position++;
      }
    }

    if (unrecognized.length()>0)
    {
      if (log!=null)
        log.debug("Text was not recognized "+Decoder.toString(unrecognized.toString()));

      atts = new AttributesImpl();
      atts.addAttribute("", "text", "text", "CDATA", unrecognized.toString());
      if (localizable)
      {
        atts.addAttribute("", "line", "line", "CDATA", String.valueOf(lineNumber));
        atts.addAttribute("", "column", "column", "CDATA", String.valueOf(columnNumber));
View Full Code Here

Examples of org.xml.sax.helpers.AttributesImpl

    // Start document
    lexer.startDocument();

    // Start 'text' element, which the parser dispatch
    lexer.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

Examples of org.xml.sax.helpers.AttributesImpl

    {
      if ((namespaceURI!=null) && (namespaceURI.equals(LexicalProcessor.NS_OUTPUT)) &&
          (localName.equals(LexicalProcessor.OUTPUT)))
      {
        contentHandler.startPrefixMapping("", NS_OUTPUT);
        contentHandler.startElement(NS_OUTPUT, OUTPUT, OUTPUT, new AttributesImpl());

        handleEndDocument();

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

Examples of org.xml.sax.helpers.AttributesImpl

          locatorImpl.setColumnNumber(next.columnnumber);
        }

        if ((!flatten) || (previous==null) || (!previous.symbol.equals(next.symbol)))
        {
          AttributesImpl atts = new AttributesImpl();
          if (localizable)
          {
            atts.addAttribute("", "line", "line", "CDATA", String.valueOf(next.linenumber));
            atts.addAttribute("", "column", "column", "CDATA", String.valueOf(next.columnnumber));
          }

          contentHandler.startElement(NS_OUTPUT, next.symbol, next.symbol, atts);
        }
View Full Code Here

Examples of org.xml.sax.helpers.AttributesImpl

    while (!stack.isEmpty());
  }

  private void fireException() throws SAXException
  {
    AttributesImpl atts = new AttributesImpl();
    atts.addAttribute("", "symbol", "symbol", "CDATA", exception.getSymbol());
    atts.addAttribute("", "text", "text", "CDATA", exception.getText());
    atts.addAttribute("", "line-snippet", "line-snippet", "CDATA", exception.getLineSnippet());
    atts.addAttribute("", "localized", "localized", "CDATA", String.valueOf(exception.isLocalized()));
    atts.addAttribute("", "line-number", "line-number", "CDATA",
                      String.valueOf(exception.getLineNumber()));
    atts.addAttribute("", "column-number", "column-number", "CDATA",
                      String.valueOf(exception.getColumnNumber()));
    contentHandler.startElement(NS_OUTPUT, "exception", "exception", atts);
    contentHandler.endElement(NS_OUTPUT, "exception", "exception");
  }
View Full Code Here

Examples of org.xml.sax.helpers.AttributesImpl

  }

  private void fireEvents() throws SAXException
  {
    contentHandler.startPrefixMapping("", NS_OUTPUT);
    contentHandler.startElement(NS_OUTPUT, OUTPUT, OUTPUT, new AttributesImpl());

    String symbol = grammar.getStartSymbol();
    contentHandler.startElement(NS_OUTPUT, symbol, symbol, new AttributesImpl());

    Stack stack = new Stack();
    StackNodeList next = root;
    char[] text = null;
    int position = 0;
    int lastposition = 0;
    line = 1;
    column = 1;

    if (locatorImpl!=null)
    {
      locatorImpl.setLineNumber(line);
      locatorImpl.setColumnNumber(column);
    }

    while (next!=null)
    {
      if (next.node instanceof NonterminalStackNode)
      {
        if (text!=null)
        {
          contentHandler.characters(text, position, (lastposition+1)-position);
          increasePosition(text, position, (lastposition+1)-position);

          if (locatorImpl!=null)
          {
            locatorImpl.setLineNumber(line);
            locatorImpl.setColumnNumber(column);
          }

          text = null;
        }

        NonterminalStackNode nonterminal = (NonterminalStackNode)next.node;

        AttributesImpl atts = new AttributesImpl();

        /*if (localizable)
        {
          atts.addAttribute("", "line", "line", "CDATA", String.valueOf(next.linenumber));
          atts.addAttribute("", "column", "column", "CDATA", String.valueOf(next.columnnumber));
View Full Code Here

Examples of org.xml.sax.helpers.AttributesImpl

  public void toXML(ContentHandler contentHandler) throws SAXException
  {
    if (action.symbol!=null)
      contentHandler.startElement(ExtendedBacktrackingParserProcessor.NS_OUTPUT, action.symbol,
                                  action.symbol, new AttributesImpl());

    if (first!=null)
      first.toXML(contentHandler);

    if (second!=null)
View Full Code Here

Examples of org.xml.sax.helpers.AttributesImpl

      log.debug("Parser found "+next.size()+" alternatives");

    System.out.println();

    contentHandler.startPrefixMapping("", NS_OUTPUT);
    contentHandler.startElement(NS_OUTPUT, OUTPUT, OUTPUT, new AttributesImpl());

    int index = 1;
    while (!next.isEmpty())
    {
      StackNode node = next.pop();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.