WebSphere Enterprise Service Bus バージョン 6.2.0 オペレーティング・システム: AIX、HP-UX、i5/OS、Linux、Solaris、Windows


同じ名前がついたプロパティーの差別化

同じ名前空間を持つ複数の XSD で同じ名前のタイプが定義された場合、偶然に誤ったタイプが参照される可能性があります。

Address1.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:complexType name="Address">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="city" type="xsd:string"/>
	</xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Address2.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:complexType name="Address">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="state" type="xsd:string"/>
	</xsd:sequence>
  </xsd:complexType>
</xsd:schema>

ビジネス・オブジェクトは BOFactory.create() API を通じて、グローバル XSD 構造 (complexType、simpleType、element、attribute など) の重複名をサポートしていません。それでも、これらの重複したグローバル構造は、以下の例に示すように、適正な API が使用された場合でも、他の構造に対する子として作成される可能性があります。

Customer1.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:tns="http://Customer1"
 targetNamespace="http://Customer1">
  <xsd:import schemaLocation="./Address1.xsd"/>
  <xsd:complexType name="Customer">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="address" type="Address"/>
	</xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Customer2.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:tns="http://Customer2"
 targetNamespace="http://Customer2">
  <xsd:import schemaLocation="./Address2.xsd"/>
  <xsd:complexType name="Customer">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="address" type="Address"/>
	</xsd:sequence>
  </xsd:complexType>
</xsd:schema>

両方の Customer address フィールドにデータを取り込んだ後、Address を作成するために BOFactory.create() を呼び出すと、結果としての子ビジネス・オブジェクトが誤って設定される可能性があります。これを避けるには、Customer DataObject に対して createDataObject("address") API を呼び出します。これにより、ビジネス・オブジェクトは import の schemaLocation に従うため、正しいタイプの子が生成されます。

	DataObject customer1 = ...

	// Address の子を作成する誤った方法
	// これは Address1.xsd Address または Address2.xsd Address のタイプを
	// 作成する場合がある
	DataObject incorrect = boFactory.create("", "Address");
	customer1.set("address", incorrect);

	// Address の子を作成する正しい方法
	// これにより Address1.xsd Address のタイプが作成されることが保証される
	customer1.createDataObject("address");

concept 概念トピック

ご利用条件 | フィードバック


タイムスタンプ・アイコン 最終更新: 2010/07/05


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.doc/doc/cbo_inctyperes.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
このインフォメーション・センターでは Eclipse テクノロジーが採用されています (http://www.eclipse.org)。