你在这里: Popular Formats > XML(可扩展标记语言)读/写 > xfMap > Feature Mapping Rules > FME特征建筑(定义<特征内容地图>元素下映射规则)
FME特色建设
(定义<特征内容地图>元素下映射规则)

A mapping rule[R1From the元件,一个元件相匹配Ë可能无法执行所有必要的映射Ë的子元素。在这种情况下,额外的映射规则匹配Ë’s children should be specified under the<功能内容地图>元素。

回想一下,当一个FME特征正在建设中(即,至少一个Feature mapping rule被激活),则特征搜索集只能包括从映射规则<功能内容地图>元素。当激活时,这些映射规则work on the current feature that is under construction; they do not specify the construction of a new FME feature.

Consider the following input XML document,points2.xml

points2.xml

< ?xml version=”1.0”?>            

A mapping rule[R1下所定义的元件,相匹配的<点>element will have difficulty extracting information from all the元素。

[Recall that the extract expression does not currently support index access for the matched element’s children. All[R1是ble to do now, is to extract data from the first元素。

An extract expression defined in a mapping rule matching the<点>element will be unable to reach the otherelements, since itsexpression stringcan only refer to the first元素。To overcome this limitation, we need to define mapping rules in the<功能内容地图>元素匹配元素。

Let[R2是下的映射规则<功能内容地图>元素匹配元素。什么时候[R2activates it will suspend[R1,and work with the same FME feature that[R1创建。下面xfMap文件,feature_content.xmp,这是否正是:

feature_content.xmp

<?XML版本= “1.0”?> <!DOCTYPE xfMap SYSTEM “xfMap.dtd”> <!xfMap> <特征地图> <! - 调用此映射规则R1  - > <映射匹配= “点”>   <特征内容地图> <! - 调用此映射规则R2  - > <映射匹配= “彩色”> <属性> <属性> <名称> <字面EXPR =”色。 “/> <提取EXPR =” @类型 “/>  <值> <提取EXPR =” @值“/>      

什么时候thepoints2.xmlandfeature_content.xmp文档被送入XML阅读器中,FME具有输出是:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: '
Attribute: color.blue' has value 0.596'
属性:color.green”具有价值0.233'
Attribute: color.red' has value 0.324'
属性:XML_TYPE“具有价值xml_no_geom”
几何类型:未知(0)
=============================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: '
属性:color.blue”具有价值0.554'
Attribute: color.green' has value 0.948'
属性:color.red”具有价值0.874'
属性:XML_TYPE“具有价值xml_no_geom”
几何类型:未知(0)
=============================================================

这是发生了什么:

功能搜索的设置内容(步骤之后)

映射规则的状态[Rp(后工序)

1。

该Feature-search-set is initialized:

No feature mapping rules are executing, so the mapping rules defined in在元素feature_content.xmpdocument are added to the feature-search-set.

{[R1}

[R1:de-activated

[R2:de-activated

2。

XML读取器读取的开始标记<points>element:

No mapping rules in the feature-search-set matches the <points>元素。该reader continues reading the contents of the元素。

{[R1}

[R1:de-activated

[R2:de-activated

3。

该XML Reader reads the start-tag of a <point>element:

该mapping rule[R1in the feature-search-set matches the <point>元素。[R1被激活。[R1也是在执行中因状态<点>元件是当前上下文元素。

Since at least one feature mapping rule is activated (i.e.,[R1),特征搜索集的内容随后将默认为含有下的映射规则<特征化内容地图>element, in this case, it is just[R2

{[R2}

[R1:activated, executing

[R2:de-activated

4。

该XML Reader reads the start-tag of a <色>element:

该mapping rule[R2in the feature-search-set matches the <色>元素。[R2被激活。没有品牌的新FME功能创建因为[R2在被定义<Feature内容映射>元素。该element is also the context element so that[R1is suspended, and[R2现在执行。

Feature mapping rule[R2具有<属性>element,[R2提供这些属性到正在构造的FME特征。

{[R2}

[R1:激活,悬浮

[R2:activated, executing

5。

该<色>元素结束标记被读取。Thiselement initially triggered the activation of[R2,所以[R2is de-activated (see the section titled映射规则状态).

该功能搜索集不会改变,因为有至少一个激活的Feature mapping rule,that is[R1

{[R2}

[R1:activated, executing

[R2:de-activated

6。

步4) and 5) are repeated for the next two <色>元素。

{[R2}

...

7。

该<point>元素结束标记被读取。

[R1被取消激活。XML读取器认为在建FME功能是完成时[R1de-activates, this is because[R1Feature mapping rule在所定义的<Feature-map>元素。

NoFeature mapping rulesare activated, so the mapping rules defined in在元素feature_content.xmpdocument becomes the feature-search-set.

{[R1}

[R1:de-activated

[R2:de-activated

8.

步骤3)至7)被重复用于第二<point>元素。

...

...

9.

该<points>元素结束标记被读取。该XML阅读器已经读完了输入的XML文档。

{}

[R1:de-activated

[R2:de-activated

考虑另一个例子:

points3.xml

< ?xml version = " 1.0 " ?>        0.324 0.233 0.596           0.874 0.948 0.554    

feature_content2.xmp

< ?xml version="1.0">                                                          

什么时候thepoints3.xmlfeature_content2.xmp文档输入到XML阅读器,下面的FME的特点是输出:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
功能类型:myPoint_0'
Attribute: fill_color.blue' has value 0.596'
Attribute: fill_color.green' has value 0.233'
Attribute: fill_color.red' has value 0.324'
Attribute: location.x ' has value 10.0'
Attribute: location.y ' has value 0.0'
Attribute: outline_color.blue' has value 1.0'
Attribute: outline_color.green' has value 1.0'
属性:outline_color.red”具有值1.0'
属性:XML_TYPE“具有价值xml_no_geom”
几何类型:未知(0)
=============================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
功能类型:myPoint_1'
Attribute: fill_color.blue' has value 0.554"'
属性:fill_color.green”具有价值0.948'
Attribute: fill_color.red' has value 0.874'
属性:location.x“具有价值5.0”
Attribute: location.y ' has value 5.0'
属性:outline_color.blue”具有值0.5'
属性:outline_color.green”具有值0.5'
Attribute: outline_color.red' has value 0.5'
属性:XML_TYPE“具有价值xml_no_geom”
几何类型:未知(0)
=============================================================