Subject:alternative for 'exists' Author:DG Sarbo Date:16 Jul 2009 05:07 AM
When making a mapping, the resulting xml has sometimes (optional) empty segments/tags. Because we want to have 'clean' output, in the mapping these segments are put in a 'exists' function.
Because our organisation uses a lot of mappings with a lot of optional fields ... I am looking for a generic function that filters out the empty segments/tags. Is this possible in xquery? Could anybody point me in the right direction?
Subject:alternative for 'exists' Author:Tony Lavinio Date:10 Aug 2009 03:40 PM
There isn't an inline way to do this for everything at once in XQuery,
but there are lots of nice ways to do it between the XML output of
XQuery and the next stage.
For example, inserting this little XSLT filter into the pipeline:
will remove every element that satisfies this criteria:
- no child elements
- no attributes
- no text (defined as at least one non-whitespace character)
Subject:alternative for 'exists' Author:DG Sarbo Date:11 Aug 2009 03:34 AM Originally Posted: 11 Aug 2009 03:26 AM
Thank you for looking at this issue. This approach seems very interesting but leaves me with a question.
If I use xlst, the XML file is left unchanged?
In other words; we use xml to communicate data to customers. The input is not displayed but put into a database (by our customers). Is xslt able to change the input we send out (change the xml content), or is it primarily used for displaying purposes?
Subject:alternative for 'exists' Author:Tony Lavinio Date:11 Aug 2009 10:07 AM
XSLT and XQuery can both be used in the same fashion - they read
XML, and they write XML.
If you use the XML Pipeline inside of Stylus Studio to connect
the pieces together and then look at the resulting code, you can
see how you can directly chain them.
Or, you can just run the XSLT as a filter on your output before
sending it on.