XMLUpdater
这个变压器modifies XML documents通过执行以下一个或多个操作:
- 替换XML元素或属性。
- 代替the contents of an element or attribute.
- 删除XML元素或属性。
- 删除the contents of an XML element or attribute.
- 重命名元素或属性
- 插入新元素或属性。
For each document update, an XML path expression is used to identify the location of the items to be modified. Note that the path may refer to more than one item. If this is the case, all the items will be modified.
对于替换现有项目或插入新项目的修改,给出了两个参数,其中指定要添加到文档的值。该值可以作为简单的文本值给出,或者它可能是一个XQuery表达。
这Update功能提供文档更新操作中使用的属性值。这Documentfeature is only used to supply the XML document which is to be updated.
For each feature that enters theUpdate端口,变压器中列出的所有更新操作将应用于通过的每个功能通过Document港口。这refore, no changes will be made to the XML document if no features enter the transformer through theUpdate港口。
请注意,如果将文档直接输入到变压器参数中,则可以以两种不同的方式处理它:
- If noDocument功能将提供给变换器,将创建一个新功能以存储文档。每个更新都将应用于文档,然后将输出通过Document港口。
- IfDocument特征给变压器,每个更新都将应用于文档,然后将复制到每个文件Documentinput feature before these features are output from the transformer.
Input Ports
Input features contain the XML documents to be modified. The documents can be contained in an attribute, entered directly into the transformer, or contained in a file referenced by an attribute value.
对于进入此输入端口的每个功能,变压器中列出的每个更新都将在通过该文件输入的每个文档上执行Document输入端口。这些功能将包含文档更新中使用的属性值。
Output Ports
这Document输入功能将通过此端口输出。这些功能将包含更新的文档,该文档将存储在结果属性参数中名为的属性中。
参数
This parameter is used to specify which update features will modify a document. When this parameter is set to a list of attributes,Documentfeatures will only be modified byUpdate为这些属性共享相同值的功能。该文档将由具有相同属性值的所有更新功能进行修改。请注意,如果否,则不会更新文档Update为变压器提供具有相同“组”属性的相同值的功能。
XML文档
This parameter is used to specify the type of XML document which is to be modified. The XML may come from the input features (Parameter Value: Text or Attribute), or it may come from an external file. (Parameter Value: XML File)
当XML Input参数设置为Text或属性时,此参数用于指定XML文件。参数可以设置为属性值,或者可以直接输入XML文档。
When the XML Input parameter is set to XML File, this parameter is used to specify the location of the file. The file path may be entered directly into the parameter, or the path may come from an attribute value.
Updates
This parameter specifies the type of modification to apply to the XML document. The possible updates are:
Update Type | 描述 |
---|---|
代替 |
Each of the items referred to by the XML Path parameter will be replaced with the value given in the Value parameter. |
替换内容 |
XML路径参数引用的每个项目都将其内容替换为值参数中给出的值。 |
代替with contents |
Each of the items referred to by the XML Path parameter will be replaced with their contents. That is, the node will be removed but the node's children and text content will remain. |
删除 |
XML PATH参数引用的每个项目将从文档中删除。 |
删除contents |
XML路径参数引用的项目的内容将从文档中删除。如果路径指的是元素,则将删除引用元素的所有子元素和文本内容,而属性将被删除。如果路径指的是属性,则其值将被删除。 |
改名 |
这element or attribute referred to by the path will be renamed. Note that if the Value Type parameter is XML/XQuery, then the XQuery expression in the Value parameter should evaluate to a string or a QName object. |
作为第一个孩子插入 |
这value given in the Value parameter will be inserted as the first child of each element referred to by the XML Path parameter. |
Insert as last child |
值参数中给出的值将作为XML路径参数引用的每个元素的最后一个子插入。 |
插入以前的兄弟姐妹 |
值参数中给出的值将插入XML路径参数所引用的每个项目的父元素。它将在引用项目之前立即出现。 |
插入下一个兄弟姐妹 |
值参数中给出的值将插入XML路径参数所引用的每个项目的父元素。It will appear immediately after the referred item. |
此参数指定要更新的XML节点的位置。这里可以使用任何XQuery表达式,只要它返回输入文档中包含的节点即可。如果路径表达式评估为多个项目,则它们都将被修改。
这simplest parameter value is a path expression, for example:
/data/record/name
With this path expression, the transformer will modify every
/数据/记录[1] /名称
Similarly, a predicate may also be used to narrow the selection based on an attribute value:
/data/record[@id = "A-123"]/name
值得注意的是,由于这是XQuery表达式,因此可以使用FME XQuery函数。
Note:这XQuery functions used in the Path parameter will apply to theUpdatefeature being processed, not theDocument正在更新的功能
/数据/记录[@ id = fme:get-attribute(“record_id”)/ name。
变换器将仅修改其中包含的
/data/record[@id=fme:get-list-attribute("_ids{}")]/name
路径expression must be namespace correct. That is, the prefixes (or lack of prefixes) must match exactly the prefixes used in the input XML document. A wildcard (*) may be used as a namespace prefix. The path/*:数据将匹配A.任何名称空间中的元素,包括默认命名空间和空名称空间。类似地,通配符可以用于元素名称。路径GML:*将与GML前缀绑定的命名空间中的任何元素匹配。结合这些方法,*:*可以不使用语法。相反,应该使用单个*字符。
This parameter is used to indicate how the value of the Value parameter should be interpreted. The effects of the different values of this parameter are explained in the description of the Value parameter. In general, this parameter should be set to Plain Text if the transformer is intended to insert text content into the document, while it should be set to XML/XQuery if the transformer is intended to insert XML elements into the document.
This parameter is used to specify the new values that should be inserted into the document. If the Value Type parameter is set to Plain Text, the contents of this parameter will be encoded for safe use in an XML document. That is, < characters will be encoded as <, > characters will be encoded as > and so on.
If the Value Type parameter is set to XML/XQuery, the contents of this parameter will be interpreted as an XQuery expression. This allows the insertion of XML elements into the document. Also, this allows the use of the FME XQuery functions. For example, an XML Template (for example, from thexmltemplater.可以输入变换器作为参数值。然后将在插入文档之前进行评估。
Note:Any FME XQuery functions used in the new value will access theUpdate特征,不是Documentfeature.
参数
该参数指定是否工作台should try to validate the attribute names which are passed to any XQuery functions used in the XML Path column and the Value column.
This parameter specifies the attribute to which the updated XML document will be written. The default is_结果。
此参数指定更新的XML文档是否应以XML标题声明开头。默认情况下,输出将包含XML标题。当输出将与其他值连接到较大的XML文档时,省略标题可能很有用。
编辑变压器参数
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变换器参数菜单选项。
变压器类别
Search FME Knowledge Center
Search for samples and information about this transformer on theFME知识中心。