「XML 對映編輯器」版本注意事項

© Copyright International Business Machines Corporation 2005. All rights reserved.US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

版本注意事項

1.0 說明
2.0 限制
3.0 已知問題和暫行解決方法
   3.1 如果 minOccurs 不是 0 或 1,則會個別顯示元素陣列
   3.2 定義群組參照的常數對映時,會產生不正確的 XSL
   3.3 當執行採用群組參照的陣列子對映時,會產生不正確的 XSL

1.0 說明

此版本注意事項檔案含有 WebSphereR Integration Developer XML 對映編輯器之限制、已知問題和暫行解決方法的最新相關資訊:

2.0 限制

3.0 已知問題和暫行解決方法

3.1 如果 minOccurs 不是 0 或 1,則會個別顯示元素陣列

如果您在 XSD 綱目中,類似如下做法,將元素的 minOccurs 定義成 0 或 1 以外的值:

<element maxOccurs="max_integer" minOccurs="min_integer" name="elementName" type="yourType"/>

其中:

當您使用這項 XSD 綱目作為來源或目標時, 則 XML 對映編輯器中會顯示二或多個 elementName 項目。如果您執行一項從母元素至 elementName 的相符對映, 則 elementName 會對映多次,且可能產生非所要的對映。

暫行解決方法 1:
在執行相符對映時(來源為母元素),請對映每一個 elementName 項目。

暫行解決方法 2:
將 minOccurs 設為 0 或 1。

3.2 定義群組參照的常數對映時,會產生不正確的 XSL

類似如下範例所示,假設您的 XSD 綱目中有一個複式類型,並使用了群組參照:

<complexType name="MyType1">
    <sequence>
      <group ref="xsd1:myType1"/>
    </sequence>
</complexType>

  <group name="myType1">
    <sequence>
      <element name="emplID">
 <simpleType>
          <restriction base="int"/>
        </simpleType>       
      </element>
      <element name="location">      
        <simpleType>
          <restriction base="string">
            <maxLength value="10"/>
          </restriction>
 </simpleType>
      </element>
      <element name="data">       
        <simpleType>
          <restriction base="string">
            <maxLength value="1"/>
          </restriction>
        </simpleType>
      </element>
    </sequence>
  </group>

如果您在 XML 對映編輯器中選取這項 XSD 綱目作為目標, 且您試著將 emplID 對映至一個常數值,則這項對映將產生不正確的 XSL。

暫行解決方法如下:

  1. 首先,將元素 (emplID) 對映至來源樹中的根元素,並使用定義 XSLT 函數... 來指派常數值。
  2. 將群組中元素的其餘部分 (location, data) 對映至所要的值。

如此一來,將會產生正確的 XSL。

3.3 當執行採用群組參照的陣列子對映時,會產生不正確的 XSL

假設綱目 1 含有下列內容:

<xsd:complexType name="Raw_Materials_Type">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="materialid" type="xsd:int"/>
      <xsd:element minOccurs="0" name="quantity" type="xsd:int"/>     
    </xsd:sequence>
</xsd:complexType>

<xsd:element maxOccurs="unbounded" minOccurs="1" name="RawMaterials" type="Raw_Materials_Type"/>
     
假設綱目 2 含有下列內容:

<xsd:element maxOccurs="3" minOccurs="3" name="MaterialDataSet" type="reservedmaterialdataset"/>
<complexType name="reservedmaterialdataset">
    <sequence>
      <group ref="xsd1:reservedmaterialdatasetGroup"/>
    </sequence>
</complexType>
<group name="reservedmaterialdatasetGroup">
    <sequence>
      <element name="matID" type="xsd:int"/>
      <element name="qty" type="xsd:int"/>
    </sequence>
</group>

如果您使用 XML 對映編輯器將綱目 1 對映至綱目 2, 且您試著針對「Raw_materials 至 MaterialDataSet」建立對映(包括所有的子元素),則會產生不正確的 XSL。

暫行解決方法 1:
在綱目 2 方面, 將 minOccurs="3" 改為 minOccurs="0",並執行這兩個元素的相符對映。如此將會產生正確的 XSL。

暫行解決方法 2:

  1. 建立對映(從 materialid 對映至第一個 MaterialDataSet/matID)
  2. 使用 XPath 表示式 /RawMaterials[1]/materialid/text(),為第一個 MaterialDataSet/matID 定義 XSLT 函數...
  3. 建立對映(從 quantity 對映至第一個 MaterialDataSet/qty)
  4. 使用 XPath 表示式 /RawMaterials[1]/quantity/text(),為第一個 MaterialDataSet/qty 定義 XSLT 函數...
  5. 建立對映(從 materialid 對映至第二個 MaterialDataSet/matID)
  6. 使用 XPath 表示式 /RawMaterials[2]/materialid/text(),為第二個 MaterialDataSet/matID 定義 XSLT 函數...
  7. 建立對映(從 quantity 對映至第二個 MaterialDataSet/qty)
  8. 使用 XPath 表示式 /RawMaterials[2]/quantity/text(),為第二個 MaterialDataSet/qty 定義 XSLT 函數...
  9. 建立對映(從 materialid 對映至第三個 MaterialDataSet/matID)
  10. 使用 XPath 表示式 /RawMaterials[3]/materialid/text(),為第三個 MaterialDataSet/matID 定義 XSLT 函數...
  11. 建立對映(從 quantity 對映至第三個 MaterialDataSet/qty)
  12. 使用 XPath 表示式 /RawMaterials[3]/quantity/text(),為第三個 MaterialDataSet/qty 定義 XSLT 函數...
  13. 儲存對映,並產生 XSL
  14. 開啟 XSL 檔,並尋找類似如下的建構:
        <xsl:template name="MaterialDataSet">
             <reservedRawMatDataSet>
        ...
        <xsl:template name="MaterialDataSet_1">
             <reservedRawMatDataSet>
        ...
        <xsl:template name="MaterialDataSet_2">
             <reservedRawMatDataSet>
        ...
  15. 尋找下列字行:
     <xsl:call-template name="MaterialDataSet"/>
  16.  將下列字行附加到如下之後:

    <xsl:call-template name="MaterialDataSet_1"/>
    <xsl:call-template name="MaterialDataSet_2"/>

此時,會適當呼叫 XSL 範本,以符合您 XML 對映編輯器中的對映項目。