你在这里: Popular Formats > XML(可扩展标记语言)读/写 > xfMap > 特征映射规则 > 属性元素(处理多值)

属性元素(处理多个值)

该xfMap元件提供了两种不同的方式来处理包含多个值的属性;这些反映在其中FME特征解释其所有属性,如(名称,值)对与所述名称为属性的标识符的方式。一个FME功能还可以通过使用属性列表存储属性的集合。属性列表行为类似于原始属性,即,(名称,值)对,不同之处在于它们包含括在大括号{}中的属性名称索引。

当我们想从XML文档流信息到FME要素的属性,并将该信息映射到具有多个值的属性,那么我们就可以:

  1. use a “primitive attribute” and append, with a separator character, the multiple values into one string, or
  2. use the FME attribute list, or
  3. 保留一个属性值从多个值。

元素有一个可选类型attribute that specifies how an attribute is to be mapped into an FME feature. The valid values for the类型属性是:多值名单,和single-value,对应于a)中,b)和c)中,分别选择。

多值选项

当值了类型属性多值,那么element can carry an additional optionalDELIM要用于值的附加字符串的属性,指定的分隔符。该DELIM未指定当属性默认为逗号。

该following example sets the separator for the appended values to be the pipe character:


...

An extra attribute on the FME feature may also be created counting the number of values in the multi-value attribute. The创建计数属性是可以使用的可选属性,当类型属性被设置为多值;其有效值no,withnobeing its default value.

计数属性的名称是基于在指定的名称相同表达序列of the’s<名称>element augmented by an optional prefix and a mandatory suffix.

伯爵属性的前缀和后缀可以通过指定计数属性名称前缀count-attribute-name-suffixattributes, respectively.

Both计数属性名称前缀count-attribute-name-suffix是可选属性。为默认值计数属性名称前缀is the empty string, while the default value for thecount-attribute-name-suffixis计数。该count-attribute-name-suffix不得为空字符串时,它是存在的。

列表选项

当值了类型属性名单,then a multiple value attribute in the input XML document stream will be converted into an attribute list for the FME feature that is under construction.

单值期权

This is the default value for the类型属性。一个属性可以与一个特定的名称only have one value in the FME feature.

element can carry an additional optionaluse属性是,如果第一,最后或任何值的第一或最后一个值出来的多个值之间应使用指定。此属性的合法值为:first-valuelast-value,or any natural number in 0...(last-value- 1)。如果没有指定,则useattribute defaults to thelast-value。如果自然数被用来代替,如果它们overspecified从输入XML流多值的属性数目,那么last-valuewill be assumed.

下面的示例示出了多个值处理。考虑下面的输入XML和xfMap文件:

purchase.xml

<?XML版本= “1.0”?> <购买日期= “1999-10-20”> <项目>的无线电牙刷毛巾 <项目>肥皂瓶装水  

purchase.xmp

                                                                        

该following shows a log of the FME feature constructed when thepurchase.xmlpurchase.xmp文档被送入XML阅读器:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
功能类型:购1999-10-20'
属性:第一项“具有价值电台”
Attribute: item-at-3-(4th item)' has value Soap'
Attribute: items1' has value Radio,Toothbrush,Towel,Soap,Bottled Water'
属性:items2' 具有价值收音机:牙刷:毛巾:肥皂:瓶装水”
属性:最后一个项目“具有价值瓶装水”
属性:列表ATTR {0}“价值电台”
Attribute: list-attr{1}' has value Toothbrush'
Attribute: list-attr{2}' has value Towel'
属性:列表ATTR {3}“的价值肥皂”
Attribute: list-attr{4}' has value Bottled Water'
属性:XML_TYPE“具有价值xml_no_geom”
Attribute: list-attr{0}' is sequenced
属性:列表ATTR {1}”测序
Attribute: list-attr{2}' is sequenced
Attribute: list-attr{3}' is sequenced
属性:列表ATTR {4}”测序
几何类型:未知(0)
+========================================================================