如何在具有wso2治理的治理工件中获取AttributeValue?

如何在具有wso2治理的治理工件中获取AttributeValue?,wso2,artifact,wso2greg,Wso2,Artifact,Wso2greg,情况是这样的,我定义了一种工件类型,如下所示: <artifactType type="application/vnd.wso2-tets+xml" shortName="test" singularLabel="tests" pluralLabel="tests" hasNamespace="false" iconSet="9"> <storagePath>/applications/@{name}/@{overview_version}</storage

情况是这样的,我定义了一种工件类型,如下所示:

<artifactType type="application/vnd.wso2-tets+xml" shortName="test" singularLabel="tests" pluralLabel="tests" hasNamespace="false" iconSet="9">
    <storagePath>/applications/@{name}/@{overview_version}</storagePath>
    <nameAttribute>overview_name</nameAttribute>
    <ui>
        <list>
            <column name="Name">
                <data type="path" value="overview_name" href="/applications/@{name}"/>
            </column>
            <column name="Version">
                <data type="path" value="overview_version" href="@{storagePath}"/>
            </column>
        </list>
    </ui>
    <content>
        <table name="Overview">
            <field type="text" required="true">
                <name>Name</name>
            </field>
            <field type="text" required="true">
                <name>Version</name>
            </field>
            <field type="text-area">
                <name>Description</name>
            </field>
            <field type="options">
         <name label="Zcos">Zcos</name>
         <values class="cn.oge.wso2.populator.AlgPopulator"/>
       </field>
        </table>
    </content>
</artifactType>
public class XcosMediaTypeHandler extends Handler {

    public Resource get(RequestContext requestContext) throws RegistryException {
        return null;
    }

    public void put(RequestContext requestContext) throws RegistryException {
        Resource resource = requestContext.getResource();
        String name = "";
        String version = "";
        String description = "";
        String zcos = "";

        byte[] content = (byte[]) resource.getContent();
        ByteArrayInputStream in = new ByteArrayInputStream(content);
        OMElement docElement = null;
        try {
            StAXOMBuilder builder = new StAXOMBuilder(in);
            docElement = builder.getDocumentElement();
        } catch (Exception ae) {
            throw new RegistryException(
                    "Failed to parse the propject proposal. "
                            + "All project proposals should be in XML format.");
        }
        System.out.println("==========================================");
        OMElement firstElement = docElement.getFirstElement();
        System.out.println(firstElement);
        Iterator<OMElement> ite = firstElement.getChildElements();
        for (OMElement e = ite.next(); ite.hasNext(); e = ite.next()) {
            if (e.getLocalName().equals("name")) {
                name = e.getText();
            } else if (e.getLocalName().equals("version")) {
                version = e.getText();
            } else if (e.getLocalName().equals("description")) {
                description = e.getText();
            } else if (e.getLocalName().equals("zcos")) {
                zcos = e.getText();
            }
        }

        System.out.println("Name:" + name);
        System.out.println("Version:" + version);
        System.out.println("Description:" + description);
        System.out.println("zcos:" + zcos);         
    }

    public void importResource(RequestContext requestContext)
            throws RegistryException {
        System.out.println("importResource");
    }

    public void delete(RequestContext requestContext) throws RegistryException {

    }

    public void putChild(RequestContext requestContext)
            throws RegistryException {
        System.out.println("putChild");
    }

    public void importChild(RequestContext requestContext)
            throws RegistryException {
        System.out.println("importChild");
    }

}

在上面的代码中,我可以获得Name、Version和Description的属性值。但我无法获取Zcos的属性值。在工件的定义中,字段类型的Zos是options,字段类型的其他属性是text或text area。
为什么我不能得到Zcos的财产价值?提前谢谢

为了减少混淆,请将字段引用改为小写,如下所示

<field type="options">
  <name label="Zcos">zcos</name>
  <values class="cn.oge.wso2.populator.AlgPopulator"/>
</field>

要查找示例代码,请查找。

您可以调试处理程序并查看吗?谢谢您的回答,我将尝试it@pourquoi下面的答案对你有帮助吗?如果没有,请告诉我发生了什么?
// Get the first OMElement child with name 'overview'
OMElement elementOverview = getFirstChild(docElement, "overview");
// Get the first OMElement child with name 'zcos' and appending absolute path prefix.
String zcos = getFirstChild(elementOverview, "zcos").getText();