2015-11-03 47 views
0

我有这样的结果映射WSO2 DSS嵌套查询

<result element="lot" rowName="lotInfo"> 
     <element column="key_lot" name="lotId" exportType="SCALAR" xsdType="xs:long"/> 
     <element column="lot_number" name="lotNumber" exportType="SCALAR" xsdType="xs:string"/> 
     <call-query href="getTradeNameSQL"> 
      <with-param name="TN_CODE" query-param="trade_name"/> 
     </call-query> 
     <element column="expiry_date" name="expiryDate" exportType="SCALAR" xsdType="xs:date"/> 
     <element column="Qte_administre" name="quantiteAdministre" exportType="SCALAR" xsdType="xs:float"/> 
     <call-query href="getVocabulaireSQL"> 
      <with-param name="TYPE" query-param="unite_mesure_type"/> 
      <with-param name="VOCABULARY_DOMAIN" query-param="unite_mesure_vocab_domain"/> 
      <with-param name="CONCEPT_ID" query-param="unite_mesure"/> 
     </call-query> 
     <call-query href="getVocabulaireSQL"> 
      <with-param name="TYPE" query-param="ROUTE_ADMIN_type"/> 
      <with-param name="VOCABULARY_DOMAIN" query-param="ROUTE_ADMIN_vocab_domain"/> 
      <with-param name="CONCEPT_ID" query-param="ROUTE_ADMIN"/> 
     </call-query> 
     <element column="status_lot" name="status" exportType="SCALAR" xsdType="xs:string"/> 
    </result> 

,其结果是

<lot xmlns="http://ws.wso2.org/dataservice"> 
<lotInfo> 
    <lotId>616</lotId> 
    <lotNumber>C4368AC</lotNumber> 
    <tradeName> 
     <tradeNameInfo> 
      <code>ADACEL</code> 
      <description>ADACEL</description> 
      <agents> 
       <agentInfos> 
        <id>1002805</id> 
        <code>SCT_AG0016</code> 
        <description>dcaT</description> 
       </agentInfos> 
      </agents> 
     </tradeNameInfo> 
    </tradeName> 
    <expiryDate>2015-05-31T00:00:00.000-04:00</expiryDate> 
    <quantiteAdministre>0.5</quantiteAdministre> 
    <domains> 
     <domainValue> 
      <id>493416</id> 
      <code>INV.UnitOfMeasure2</code> 
      <description>ml (millilitre)</description> 
      <type>DosageUnit</type> 
     </domainValue> 
    </domains> 
    <domains> 
     <domainValue> 
      <id>433437</id> 
      <code>IM</code> 
      <description>Intramusculaire</description> 
      <type>AdministrationRoute</type> 
     </domainValue> 
    </domains> 
    <status>Expired</status> 
</lotInfo> 

这是正确的。

我的问题是: 正如你可以看到在xml中有两个<domains>,因为它们来自同一个查询。但是,有没有办法给它们中的每一个赋予不同的名称?

我正在使用DSS 4.2.0

谢谢。

回答

0

我认为最简单的方法来解决您的问题是取代复杂元素的每个查询,并在里面调用您的查询。通过这种方式,您可以为子查询定义元素名称。 结果可能并不完全符合您的期望,但非常接近。这是因为加入复杂的元素在XML中增加了一个新的标签,是这样的:

<lot xmlns="http://ws.wso2.org/dataservice"> 
<lotInfo> 
<lotId>616</lotId> 
<lotNumber>C4368AC</lotNumber> 
<tradeName> 
    <tradeNameInfo> 
     <code>ADACEL</code> 
     <description>ADACEL</description> 
     <agents> 
      <agentInfos> 
       <id>1002805</id> 
       <code>SCT_AG0016</code> 
       <description>dcaT</description> 
      </agentInfos> 
     </agents> 
    </tradeNameInfo> 
</tradeName> 
<expiryDate>2015-05-31T00:00:00.000-04:00</expiryDate> 
<quantiteAdministre>0.5</quantiteAdministre> 
<unit> 
    <domains> 
    <domainValue> 
     <id>493416</id> 
     <code>INV.UnitOfMeasure2</code> 
     <description>ml (millilitre)</description> 
     <type>DosageUnit</type> 
    </domainValue> 
    </domains> 
</unit> 
<route> 
    <domains> 
    <domainValue> 
     <id>433437</id> 
     <code>IM</code> 
     <description>Intramusculaire</description> 
     <type>AdministrationRoute</type> 
    </domainValue> 
    </domains> 
</route> 
<status>Expired</status> 

数据服务中的XML,你只是一个<element>标签添加到您的查询:

<element name="unit" namespace="N/A"> 
    <call-query href="getVocabulaireSQL"> 
     <with-param name="TYPE" query-param="unite_mesure_type"/> 
     <with-param name="VOCABULARY_DOMAIN" query-param="unite_mesure_vocab_domain"/> 
     <with-param name="CONCEPT_ID" query-param="unite_mesure"/> 
    </call-query> 
</element> 
<element name="route" namespace="N/A"> 
    <call-query href="getVocabulaireSQL"> 
     <with-param name="TYPE" query-param="ROUTE_ADMIN_type"/> 
     <with-param name="VOCABULARY_DOMAIN" query-param="ROUTE_ADMIN_vocab_domain"/> 
     <with-param name="CONCEPT_ID" query-param="ROUTE_ADMIN"/> 
    </call-query> 
</element>