XMLTemplater
填充一个XML文档与attribu FME特性te values. The document is provided as a template, and the transformer will use XQuery to insert attribute values and geometry information into the template.该template may be loaded from an attribute, a file, or entered directly into the transformer parameters.
Input Ports
对于进入每个特征根input port, the根XML模板进行评估,并将结果放入result属性参数。
输出端口
特征从该端口输出由变压器处理后。
参数
Grouping Sub-Features
组子功能通过参数允许更粗粒度的滤波子功能比在所述参数fme:process-features功能。当这个参数设置为属性名称的列表中,fme:process-features功能将只处理子功能具有这些属性为当前正在处理的特征相同的值。注意,这个参数对无影响根features. Each根特征将被处理并输出从变压器。
When grouping sub-features, if all features in each group are consecutive, the performance of the transformer can be improved by setting the Grouped Sub-Features are Consecutive parameter to Yes. When this value is set,根features will be processed as soon as all the applicable sub-features have arrived at the transformer. This means the transformer will operate in a non-blocking manner, rather than waiting for all features to arrive before starting to process templates. The behavior of the transformer is undefined if the features in a group do not all arrive consecutively. It is likely that some sub-features will not be processed if this happens.
In the XMLTemplater, theFME:GET属性,fme:get-list-attributeandfme:get-xml-attributefunctions are particularly useful. Only functions which do not alter the feature are permitted. See theXQuery函数文档for more information on the available functions.
该following XML template populates an XML element with the value of the ‘id’ feature attribute.
道路>
XQuery的功能可以被用来填充XML属性值,以及。
来填充列表属性的内容的XML元素的序列,使用循环遍历列表项,如在此示例中:
<道路>
{
for $road_id in fme:get-list-attribute("road_ids{}")
return
}
A common use case is to write out an XML element only if a feature attribute has a value. To do this, an if-then-else statement is used. The following example writes out the displayName element only if the feature contains adisplay_name的属性的属性,和值不为空字符串。
<道路> {如果(FME:具有属性( “DISPLAY_NAME”),而不是(FME:GET属性( “DISPLAY_NAME”)当量 “”)),然后<显示名> {FME:GET属性( “DISPLAY_NAME”)}显示名>否则()} 道路>
When a template is evaluated, it can only access the attributes of the feature which is currently being processed. In order to allow a template to access the attributes of multiple features, the concept of sub-templates was introduced. Using thefme:process-featuresfunction, the transformer can evaluate a sub-template on a set of features, and then insert the results into the first template. In the transformer interface, each sub templates will be given a name. This name will then be used in thefme:process-featurescall to identify the sub-template to evaluate. In addition, a transformer input port will be created for each sub-template. The sub-template will be processed on features which enter the corresponding transformer input. Features which enter one of these input ports will be referred to as sub-features.
In the following example, the根template constructs a
<名称> {FME:获取属性( “名称”)} 名称>
<人口> {FME:获取属性( “种群”)} 人口>
{fme:process-features("HOUSE")}
与HOUSE输入端口相关联的模板创建<房子>元素。
<所有者> {FME:获取属性( “所有者”)} 所有者>
If a single feature enters the根input and two features enter the HOUSE input, the resulting XML document could look like this:
<所有者> Jane Doe的所有者>
A template may call many sub-templates. For example, in the above example, we could add another sub-template named BUSINESS, and then used the process-features function to run this sub-template from the根模板。此外,子模板可以运行其他子模板,与子模板不得直接或间接地运行本身的限制。
选择子功能来处理
Often there is a hierarchical structure to the features that enter the XMLTemplater. For example, each village will have a number of houses, and each house will have several rooms, etc. If thefme:process-featuresfunction is used as described above, the resulting document will probably not be correct. Suppose there are two villages, each with five houses. Each village and house is represented by a separate FME feature. The village features are routed into the根输入端口,而屋特征被路由到HOUSE输入端口。
如果变压器与上面的模板运行,将有两个输出功能,符合市场预期。然而,两者的
该fme:process-features函数提供了一种方法来做到这一点。额外的乐趣ction parameters may be used to filter the sub-features which are to be processed. The second parameter is a list of attribute names, and the third is a list of attribute values. Only sub-features whose attributes match the given list of attribute names and values will be processed.
调用该函数将评估HOUSE子模板上的所有屋特征,其village_id属性当前要素的id属性相匹配。
fme:process-features("HOUSE", "village_id", fme:get-attribute("id"))
多个属性/可指定值对。在这种情况下,属性名和属性值必须包含在括号中。下面的函数调用将评估HOUSE子模板上的所有屋特征,其village_id属性当前要素的id属性相匹配,并且其num_floorsattribute is 2.
fme:process-features("HOUSE", ("village_id","num_floors"), (fme:get-attribute("id"), 2) )
Running Multiple Sub-Templates with a Single Function Call
It is possible to evaluate multiple sub-templates using a single function call. Simply pass a list of template names to thefme:process-features功能。子模板将在每个列表中指定的子功能进行评估。该功能将在他们进入了变压器的顺序进行处理。下面的函数调用处理家庭和部门子模板:
fme:process-features( ("HOUSE","BUSINESS") )
仍然可以使用的子特征选择参数时fme:process-features功能是用来评估多个子模板。
在相同的特征运行子模板
这是可能的,以评估使用正被用来评估当前模板相同特征的子模板。该FME:流程的模板function takes a name, or list of names, of sub-templates which should be evaluated. These templates will be evaluated and the results will be inserted into the current template. To evaluate a template, just enter the name of the sub-template as a function parameter. For example, while a HOUSE feature is being processed, we could evaluate the OWNER template using the following function call. The OWNER template will be evaluated using the feature that entered the HOUSE input port.
FME:流程的模板("OWNER")
To evaluate a set of templates, pass a list of names:
FME:流程的模板( ("OWNER","ADDRESS") )
这种技术可以用于模块化XML模板,通过移动重复模板结构成一个单一的位置。例如,如果两院和企业有一个地址,这个地址可以提取到一个地址模板,然后将房子和业务模板可以使用FME:流程的模板function to insert the address values. This way, the address template does not have to be duplicated inside the HOUSE and BUSINESS templates.
Geometry templates can be used to write out custom XML geometry. There are a large number of functions which allow the extraction of geometric data, and the processing of sub-templates on geometries. For more information, see theXQuery函数文档对于所有的几何函数的列表,以及如何使用子模板写出来的几何数据。
几何子模板以同样的方式作为常规子模板操作,不同之处在于几何子模板不会产生变压器的输入端口。
While a geometry template is being evaluated, the functions that access feature attributes (FME:GET属性等),仍可使用。
当指定通过模板Expression参数或模板文件参数XML模板,变压器将验证所有引用的要素属性存在于传入的功能。如果属性是从输入功能缺失(不暴露),变压器将红色突出显示不完整。当这种情况发生时,变压器的总结注释将指示缺少的属性的XML模板引用。
此外,当子模板的名称被传递到fme:process-featuresandFME:流程的模板功能名称将被验证,以确保它们匹配变压器接口提供的名称。
To override this additional validation behavior, set the parameterValidate Attribute/Template Names为No.
该attribute to which the updated XML document is written. The default is_result。
指定更新XML文档是否应该以一个XML头声明开始。默认情况下,输出将包含XML头。当输出是与其它值被连结成一个更大的XML文档省略报头可以是有用的。
Automatic Generation of XML Templates
在XMLTemplater编辑器窗口中,“生成”按钮可用于调出可用于产生可被用作一个XML模板的基础XML文档的对话框。这个对话框使用了相同的功能XMLSampleGeneratortransformer. For more information on how to use this dialog, refer to theXMLSampleGeneratordocumentation.
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, clickbeside the applicable parameter. For more information, see变压器参数菜单选项。
变压器分类
FME Licensing Level
FME Professional edition and above
Technical History
FME Factory Used: XMLTemplaterFactory
搜索FME社区亚搏国际在线官网
Search for samples and information about this transformer on theFME Community。