そのドキュメントを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>
「initialstate」と「name」を除くすべての属性をよく読みました... startElement ハンドラーで属性を取得しましたが、scxml の属性リストのサイズはゼロです。なんで?どうすればその問題を克服できますか?
編集:
public void startElement(String uri, String localName, String qName, Attributes attributes){
System.out.println(attributes.getValue("initialstate"));
System.out.println(attributes.getValue("name"));
}
これは、最初のタグを解析するときに機能しません (「null」が 2 回出力されます)。実際には、
attributes.getLength();
ゼロに評価されます。
ありがとう