0

簡単に言えば、XSLT テンプレートまたは関数を入力して、名前付きシーケンス コンストラクターを返すことは可能ですか?

たとえばFpMLには、2 つの要素 (ProductType と ProductId) だけを含む Product.model グループがあります。そのシーケンスを返す型付きテンプレートを作成できるようにしたいのですが、「as」属性に何を含めるべきかわかりません。

アップデート

便宜上、FpML スキーマの関連部分を含めます。

<xsd:group name="Product.model">
<xsd:sequence>
  <xsd:element name="productType" type="ProductType" minOccurs="0" maxOccurs="unbounded">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">A classification of the type of product. FpML defines a simple product categorization using a coding scheme.</xsd:documentation>
    </xsd:annotation>
  </xsd:element>
  <xsd:element name="productId" type="ProductId" minOccurs="0" maxOccurs="unbounded">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">A product reference identifier allocated by a party. FpML does not define the domain values associated with this element. Note that the domain values for this element are not strictly an enumerated list.</xsd:documentation>
    </xsd:annotation>
  </xsd:element>
</xsd:sequence>

したがって、この xsd:group としてテンプレートを入力できるようにしたいと考えています。これは可能ですか?

4

1 に答える 1

1

の値には、 XPATH シーケンス タイプ@asが含まれている必要があります

2 つの異なるタイプの要素のシーケンスを構築しているので、 を使用すると思いますelement()*。これは、テンプレートが要素の 0 回以上の出現を返すことを示します。

これらの要素を生成するために使用される個々のテンプレート/関数を入力し、それらを特定の要素に制限することができます。たとえば、element(ProductType)?ゼロまたは 1 つのProductType要素を示します。

<xsl:template name="ProductModel" as="element()*">
  <xsl:call-template name="ProductType" />
  <xsl:call-template name="ProductId" />
</xsl:template>

<xsl:template name="ProductType" as="element(ProductType)?">
  <ProductType></ProductType>
</xsl:template>

<xsl:template name="ProductId" as="element(ProductId)?">
  <ProductId></ProductId>
</xsl:template>

編集:シーケンス型構文の詳細を調べると、要素の定義は次のとおりです。

ElementTest ::= "要素" "(" (ElementNameOrWildcard ("," TypeName "?"?)?)? ")"

2 番目のパラメーターtype nameQNameです

2.5.3 SequenceType Syntaxにリストされている例の 1 つ:

element(*, po:address)型注釈 po:address (または po:address から派生した型) を持つ任意の名前の要素ノードを参照します。

したがって、次のことができる可能性があります(ただし、おそらくSaxon-EEなどのスキーマ対応プロセッサが必要になるでしょう):

<xsl:template name="ProductModel" as="element(*,fpml:Product.model)*">
  <xsl:call-template name="ProductType" />
  <xsl:call-template name="ProductId" />
</xsl:template>

<xsl:template name="ProductType" as="element(ProductType)?">
  <ProductType></ProductType>
</xsl:template>

<xsl:template name="ProductId" as="element(ProductId)?">
  <ProductId></ProductId>
</xsl:template>
于 2010-02-22T01:45:59.660 に答える