Can't read some attributes with SAX

Posted by akappa on Stack Overflow See other posts from Stack Overflow or by akappa
Published on 2010-01-13T11:28:32Z Indexed on 2010/04/12 7:53 UTC
Read the original article Hit count: 373

Filed under:
|
|

Hi all,

I'm trying to parse that document with SAX:

<scxml version="1.0" initialstate="start" name="calc"> 
  <datamodel> 
      <data id="expr" expr="0" /> 
      <data id="res" expr="0" /> 
  </datamodel> 
  <state id="start"> 
      <transition event="OPER" target="opEntered" /> 
      <transition event="DIGIT" target="operand" /> 
  </state> 
  <state id="operand"> 
      <transition event="OPER" target="opEntered" /> 
      <transition event="DIGIT" /> 
  </state> 
</scxml>

I read all the attributes well, except "initialstate" and "name"... I get the attributes with the startElement handler, but the size of the attribute list for scxml is zero. Why? How I can overcome that problem?

Edit:

public void startElement(String uri, String localName, String qName, Attributes attributes){
  System.out.println(attributes.getValue("initialstate"));
  System.out.println(attributes.getValue("name")); 
}

that, when parsing the first tag, doesn't work (prints "null" two times). In fact,

attributes.getLength();

evaluates to zero.

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about sax