我正在尝试执行E4X查询(在下面的xml上),该查询将返回包含“metadata”节点的所有“访问者”节点,其中“name”属性等于“Required”。
我试过......
type.accessor.(metadata.@name == "Required")
...但这仅适用于只有1个元数据节点的访问者节点。
任何线索?
<type name="org.springextensions.actionscript.ioc.testclasses::PersonRequiredName" base="org.springextensions.actionscript.ioc.testclasses::Person" isDynamic="false" isFinal="false" isStatic="false">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\PersonRequiredName.as"/>
<arg key="pos" value="935"/>
</metadata>
<extendsClass type="org.springextensions.actionscript.ioc.testclasses::Person"/>
<extendsClass type="Object"/>
<constructor>
<parameter index="1" type="String" optional="true"/>
<parameter index="2" type="int" optional="true"/>
<parameter index="3" type="Boolean" optional="true"/>
</constructor>
<accessor name="name" access="readwrite" type="String" declaredBy="org.springextensions.actionscript.ioc.testclasses::PersonRequiredName">
<metadata name="Required"/>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\PersonRequiredName.as"/>
<arg key="pos" value="1163"/>
</metadata>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\PersonRequiredName.as"/>
<arg key="pos" value="1249"/>
</metadata>
</accessor>
<variable name="age" type="int">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="1070"/>
</metadata>
</variable>
<accessor name="siblings" access="readonly" type="Array" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3724"/>
</metadata>
</accessor>
<method name="addFriend" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person" returnType="void">
<parameter index="1" type="org.springextensions.actionscript.ioc.testclasses::Person" optional="false"/>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="2424"/>
</metadata>
</method>
<method name="toString" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person" returnType="String">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3181"/>
</metadata>
</method>
<method name="helloWorld" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person" returnType="String">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="2159"/>
</metadata>
</method>
<method name="equals" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person" returnType="Boolean">
<parameter index="1" type="org.springextensions.actionscript.ioc.testclasses::Person" optional="false"/>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="1932"/>
</metadata>
</method>
<method name="hasSibling" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person" returnType="Boolean">
<parameter index="1" type="org.springextensions.actionscript.ioc.testclasses::Person" optional="false"/>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="2789"/>
</metadata>
</method>
<accessor name="writeObject" access="writeonly" type="Object" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3950"/>
</metadata>
</accessor>
<variable name="colleague" type="org.springextensions.actionscript.ioc.testclasses::Person">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="1132"/>
</metadata>
</variable>
<variable name="anArray" type="Array">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="1166"/>
</metadata>
</variable>
<method name="addSibling" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person" returnType="void">
<parameter index="1" type="org.springextensions.actionscript.ioc.testclasses::Person" optional="false"/>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="2605"/>
</metadata>
</method>
<variable name="anObject" type="Object">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="1197"/>
</metadata>
</variable>
<accessor name="friends" access="readwrite" type="Array" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3583"/>
</metadata>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3645"/>
</metadata>
</accessor>
<accessor name="isMarried" access="readwrite" type="Boolean" declaredBy="org.springextensions.actionscript.ioc.testclasses::Person">
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3434"/>
</metadata>
<metadata name="__go_to_definition_help">
<arg key="file" value="C:\workspace\spring-actionscript\core\src\test\actionscript\org\springextensions\actionscript\ioc\testclasses\Person.as"/>
<arg key="pos" value="3502"/>
</metadata>
</accessor>
</type>
答案 0 :(得分:4)
这似乎有效:
type.accessor.(hasOwnProperty("metadata") && metadata.attribute("name").contains("Required"))
答案 1 :(得分:0)
所有关于括号的内容。
试试这个(清洁)
var list:XMLList;
xmlList = type.accessor.metadata.(@name == "Required");