2015-11-03 80 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>