匹配表达式

The匹配表达式returns the mapping rule’s matched element’s local-name, namespace-prefix, namespace-uri, QName, or sequence number. This expression is useful to retrieve the name of the matched element in the case that a wildcard was used in the匹配表达式, or to determine a unique identifier for an element. It is represented in the xfMap document with theelement, and it has the following general form:

The表达式字符串(i.e., the expr attribute) specifies whether the local-name, the namespace-prefix, the namespace-uri, QName, or the sequence number of the matched element is to be returned. The valid values for the expression string are local-name, prefix, uri, qname, and sequence. The sequence number is a period-separated list of numbers which identify the path from the root of the xml tree to the child element where the matched expression is evaluated.

祖先属性是可选的。它的值指示expr属性应用于哪个祖先元素。“祖先”属性的有效值为self、parent、grandparent或非负数,self、parent和grandparent分别等于0、1和2。祖先属性的默认值是self。

路径属性也是可选的。指定后,表达式返回从祖先到self的路径,其中self是匹配的元素。路径中的值类型将与expr属性中指示的值类型相同。路径中的每个组件由“/”分隔。path属性的值指示返回路径的起点。路径属性的有效值为self、parent、grandparent、root或非负数,self、parent和grandparent分别等于0、1和2,root等于从匹配元素到根的计数。路径属性的默认值是self。

前缀绑定属性是可选的。仅当expr设置为prefix时才适用。此属性的有效值是dataset或xfMap。前缀绑定属性的默认值是dataset。

例子

三_播放器.xml

三_玩家.xmp

<匹配expr="local-name"/>        <匹配expr="prefix"/>        <匹配的expr=“uri”/>        <匹配expr="qname"/><matched expr=“序列”/>        <匹配的expr=“qname”祖先=“父”/>

FME features constructed:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Feature Type: `player' Attribute(string): `QName' has value `Laura' Attribute(string): `Sequence Number' has value `1.3' Attribute(string): `local-name' has value `Laura' Attribute(string): `ns-prefix' has value `' Attribute(string): `ns-uri' has value `http://schemas.sports.com/players' Attribute(string): `Parent-QName' has value `players' Attribute(string): `xml_type' has value `xml_no_geom' Geometry Type: Unknown (0) =================================================================== +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Feature Type: `player' Attribute(string): `QName' has value `pl2:Sharen' Attribute(string): `local-name' has value `Sharen' Attribute(string): `ns-prefix' has value `pl2' Attribute(string): `ns-uri' has value `http://schemas.sports.com/2/players' Attribute(string): `Parent-QName' has value `players' Attribute(string): `xml_type' has value `xml_no_geom' Geometry Type: Unknown (0) =================================================================== +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Feature Type: `player' Attribute(string): `QName' has value `Claudia' Attribute(string): `local-name' has value `Claudia' Attribute(string): `ns-prefix' has value `' Attribute(string): `ns-uri' has value `http://schemas.sports.com/players' Attribute(string): `Parent-QName' has value `players' Attribute(string): `xml_type' has value `xml_no_geom' Geometry Type: Unknown (0) ===================================================================