Openedge 10.2 X文档节点属性顺序
Openedge 10.2 X-document node attributes order
OE 中是否有设置节点属性顺序的方法?
我需要这个结果:
<MyNode MyNode="aaa" Attribute1="bbb" Attribute2="ccc" Attribute3="ddd"/>
我使用这个代码:
hDoc:CREATE-NODE(hAttribute, "MyNode", "ELEMENT").
hAttribute:SET-ATTRIBUTE("MyNode", "aaa").
hAttribute:SET-ATTRIBUTE("Attribute1", "bbb").
hAttribute:SET-ATTRIBUTE("Attribute2", "ccc").
hAttribute:SET-ATTRIBUTE("Attribute3", "ddd").
hNode:APPEND-CHILD(hAttribute).
但它一直在创建这个混乱的输出:
<MyNode Attribute1="bbb" MyNode="aaa" Attribute2="ccc" Attribute3="ddd"/>
还是因为节点名和属性名相同?但是必须有一种方法可以将该节点名称属性放在首位......
感谢您的帮助!
XML 个属性的顺序无关紧要 (https://www.w3.org/TR/2008/REC-xml-20081126/#sec-starttags)
Note that the order of attribute specifications in a start-tag or
empty-element tag is not significant.
使用 DOM 解析器您无法控制顺序 - 请参阅 https://knowledgebase.progress.com/articles/Article/000034225
如果您使用 SAX-WRITER - 因为它是流式传输 - 您可以控制顺序:
def var lcc as longchar no-undo.
def var hsax as handle no-undo.
create sax-writer hsax.
hsax:set-output-destination( "longchar", lcc ).
hsax:formatted = true.
hsax:start-document().
hsax:start-element( "MyNode" ).
hsax:insert-attribute( "MyNode", "aaa" ).
hsax:insert-attribute( "Attribute1", "bbb" ).
hsax:insert-attribute( "Attribute2", "ccc" ).
hsax:insert-attribute( "Attribute3", "ddd" ).
hsax:end-element( "MyNode" ).
hsax:end-document().
message "sax" skip string( lcc ) skip view-as alert-box.
两者见https://abldojo.services.progress.com:443/#/?shareId=5e1484014b1a0f40c34b8c1f
OE 中是否有设置节点属性顺序的方法?
我需要这个结果:
<MyNode MyNode="aaa" Attribute1="bbb" Attribute2="ccc" Attribute3="ddd"/>
我使用这个代码:
hDoc:CREATE-NODE(hAttribute, "MyNode", "ELEMENT").
hAttribute:SET-ATTRIBUTE("MyNode", "aaa").
hAttribute:SET-ATTRIBUTE("Attribute1", "bbb").
hAttribute:SET-ATTRIBUTE("Attribute2", "ccc").
hAttribute:SET-ATTRIBUTE("Attribute3", "ddd").
hNode:APPEND-CHILD(hAttribute).
但它一直在创建这个混乱的输出:
<MyNode Attribute1="bbb" MyNode="aaa" Attribute2="ccc" Attribute3="ddd"/>
还是因为节点名和属性名相同?但是必须有一种方法可以将该节点名称属性放在首位...... 感谢您的帮助!
XML 个属性的顺序无关紧要 (https://www.w3.org/TR/2008/REC-xml-20081126/#sec-starttags)
Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.
使用 DOM 解析器您无法控制顺序 - 请参阅 https://knowledgebase.progress.com/articles/Article/000034225
如果您使用 SAX-WRITER - 因为它是流式传输 - 您可以控制顺序:
def var lcc as longchar no-undo.
def var hsax as handle no-undo.
create sax-writer hsax.
hsax:set-output-destination( "longchar", lcc ).
hsax:formatted = true.
hsax:start-document().
hsax:start-element( "MyNode" ).
hsax:insert-attribute( "MyNode", "aaa" ).
hsax:insert-attribute( "Attribute1", "bbb" ).
hsax:insert-attribute( "Attribute2", "ccc" ).
hsax:insert-attribute( "Attribute3", "ddd" ).
hsax:end-element( "MyNode" ).
hsax:end-document().
message "sax" skip string( lcc ) skip view-as alert-box.
两者见https://abldojo.services.progress.com:443/#/?shareId=5e1484014b1a0f40c34b8c1f