Skip to main content
Open

xquery code samples

Related products:Transformers
  • October 18, 2018
  • 5 replies
  • 76 views

Forum|alt.badge.img+3

XMLXqueryExploder and XMLXQueryUpdater are very powerful transformers when you use XML inside FME but they lack an easy starting point. It would be such an improvement if the "XQuery Expression window" had code samples in the left panel (similar to the XQuery Functions) providing the user with basic code snippets that would help them forward quickly.

Such snippets for example could be
- How do you count child-nodes
- Replace content of a property
- Replace content of a node based on a string in child-node
- Find domains from an XML

5 replies

antoine
Enthusiast
Forum|alt.badge.img+7
  • Enthusiast
  • September 3, 2019

I agree, this notation is used in many transformers (JSONTemplater, GeometryPartExtractor etc..) and should be improved (https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/xquery_samples.htm is not enough).


Forum|alt.badge.img+6

Agreed. Am just struggling with some simple questions which I cannot find answers to, even though support chat. For example, how can you mix in strings and XQuery functions? It's either not possible or the syntax is not easy to figure out as there's no example of such thing. So for example trying to do something like {"Result": "Database fme:get-attribute("database_id"): created"} throws an error. You can easily do this in an AttributeManager instead so I'm not sure the JSONTemplater is the right answer in such cases if this is not possible.


ebygomm
Influencer
Forum|alt.badge.img+48
  • Influencer
  • November 8, 2019

There are a code examples in answers to various questions, it would be great if these could be gathered together as code samples


ebygomm
Influencer
Forum|alt.badge.img+48
  • Influencer
  • November 8, 2019

@dbaldacchino

I'm not familiar with the JSON templater, i've been wrestling with the XMLXQueryUpdater, but for that you would use pipes to join a string and an xquery function

e.g.

"Date:"||{fme:get-attribute("test")}

Forum|alt.badge.img+6

Really great tip @ebygomm, very much appreciated!!

XQuery syntax to insert function within a string:

'

Result:

'

Would be great to add this little gem to the help documentation :)