Skip to main content

I'm trying to create an xml document where part of the information in the comment is coming from an attribute. However in the XMLTemplater everything within a comment is output untouched, including {fme:get-attribute("_comment")}.

 

Thoughts on how to work around this?

Attached is a sample workspace demonstrating the issue.

Build 2022.0

 

If I create an attribute in advance: <!-- comment should resolve attribute @Value(_creation_instance)--> and use {fme:get-attribute("_comment")},

then the braces are replaced with &ly; and &gt;.

If I use {fme:get-xml-attribute("_comment")},

there are some xml parsing warnings:

XMLTemplater (XMLTemplaterFactory): The following error occurred near line 1, column 51 of the query:

XMLTemplater (XMLTemplaterFactory): invalid content passed to fn:parse-xml(): loader parsing error: Extra content at the end of the document

and the resultant xml does not contain the comment at all.

Hi @jdh,

Isn't this what you are looking for: xquery - Write expression inside xml comment - Stack Overflow?

 

In your case, try to replace the following:

<!-- comment should resolve attribute {fme:get-attribute("_comment")}-->

with:

{comment {concat('comment should resolve attribute ',fme:get-attribute("_comment")) }}


Hi @jdh,

Isn't this what you are looking for: xquery - Write expression inside xml comment - Stack Overflow?

 

In your case, try to replace the following:

<!-- comment should resolve attribute {fme:get-attribute("_comment")}-->

with:

{comment {concat('comment should resolve attribute ',fme:get-attribute("_comment")) }}

That does seem to do the trick, though I will probably build the full comment outside and just use {comment {fme:get-attribute("_comment")}}


That does seem to do the trick, though I will probably build the full comment outside and just use {comment {fme:get-attribute("_comment")}}

sure, that's up to you :)


Reply