Skip to main content
Question

resolve attribute references in comments in XMLTemplater

  • December 15, 2022
  • 3 replies
  • 21 views

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor

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.

3 replies

thijsknapen
Contributor
Forum|alt.badge.img+10
  • Contributor
  • December 15, 2022

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")) }}


jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • December 15, 2022
thijsknapen wrote:

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")}}


thijsknapen
Contributor
Forum|alt.badge.img+10
  • Contributor
  • December 15, 2022
jdh wrote:

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 :)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings