How can I via xquery filtering get the whole xml file and not only the nodes that correspond to the filtering? - filtering

Is it possible to get the the aggregated xml file using filtering in xquery?
I have the following xquery command
xquery declare default element namespace \"http://www.satisfactory-project.eu/XMLSchema/v1.0/common\"; collection('vagelisdb')/SensorInfo/Position[x>4]
I get the filtered nodes but they include only a part of the xml, not the whole xml.
<Position xmlns="http://www.satisfactory-project.eu/XMLSchema/v1.0/common"><x>10</x><y>12</y><z>20</z><Unit>Meters</Unit></Position>
I want to get
<?xml version="1.0" encoding="UTF-8"?><SensorInfo xmlns="http://www.satisfactory-project.eu/XMLSchema/v1.0/common">
<ID>sensor_1</ID>
<Type>DepthCamera</Type>
<Position>
<x>10</x>
<y>12</y>
<z>20</z>
<Unit>Meters</Unit>
</Position>
<Space>Edw</Space>

sure, you just need to use the document as the predicate context node instead of that element:
collection('vagelisdb')[SensorInfo/Position/x>4]

Related

Mirth -> HL7 into XML conversion Ques

I'm new to the Mirth Connect When I tried to convert HL7 into XML I 'm struggling.Suppose my HL7 messages have repeat segments like ORC in ORM Messages how to iterate that.
below is my code:
tmp['Messages']['orderList']['order'][count]['provider']=msg['ORC'][count]['ORC.10']['ORC.10.1'].toString();
but it is throwing an error:
`TypeError: Cannot read property "provider"` from undefined.
please help me to proceed further.
It's failing because your count is higher than the number of elements returned by tmp['Messages']['orderList']['order'], so it is returning undefined. The short answer is that you need to add another order node to tmp['Messages']['orderList'] before you can access it. It's hard to say how best to do that without seeing more of your code, requirements, outbound template, etc... Most frequently I build the node first, and then use appendChild to add it.
A simple example would be:
var tmp = <xml>
<Messages>
<orderList />
</Messages>
</xml>;
var prov = 12345;
var nextOrder = <order>
<provider>{prov}</provider>
</order>;
tmp.Messages.orderList.appendChild(nextOrder);
After which, tmp will look like:
<xml>
<Messages>
<orderList>
<order>
<provider>12345</provider>
</order>
</orderList>
</Messages>
</xml>
The technology you are using to work with xml is called e4x, and it's running on the Mozilla Rhino Javascript engine. Here are a couple resources that might help you.
https://web.archive.org/web/20181120184304/https://wso2.com/project/mashup/0.2/docs/e4xquickstart.html
https://developer.mozilla.org/en-US/docs/Archive/Web/E4X/Processing_XML_with_E4X

Jaspersoft REST API folder traversing, XML PDF extraction

Currently trying to extract an XML document that returns all the files in a particular folder, after which I can return the XML document containing files in a given folder. In the below JPG, I want to extract files from folder '02_17_2018', which is a sub-folder under '/LatestJLIPDFs' using the Jaspersoft REST API (see image below).
Basically, I'm trying to match the query http://(host):(port)/jasperserver[-pro]/rest_v2/resources?(parameters) with the Jaspersoft REST API to get to the '02_17_2018'. I've tried several different parameters, none of which seem to work. Here is a list of attempted parameters,
folderURI=/LatestJLIPDFs/02_17_2018&type=file
folderURI=/02_17_2018&type=file
folderURI=/LatestJLIPDFs&type=file&q=02_17_2018
folderURI=LatestJLIPDFs/02_17_2018&type=folder&q=02_17_2018
among many more attempts. Any hints to how the files in '02_17_2018' can be extracted?
I think your problem is related to parameter name folderURI. In the documentation, it looks like folderUri.
Let's try to write it in camel case as in my example:
http://localhost:8080/jasperserver-pro/rest_v2/resources?folderUri=/public&type=file&recursive=false

How to make a section optional when mapped to optional data in a Word OpenXml Part?

I'm using OpenXml SDK to generate word 2013 files. I'm running on a server (part of a server solution), so automation is not an option.
Basically I have an xml file that is output from a backend system. Here's a very simplified example:
<my:Data
xmlns:my="https://schemas.mycorp.com">
<my:Customer>
<my:Details>
<my:Name>Customer Template</my:Name>
</my:Details>
<my:Orders>
<my:Count>2</my:Count>
<my:OrderList>
<my:Order>
<my:Id>1</my:Id>
<my:Date>19/04/2017 10:16:04</my:Date>
</my:Order>
<my:Order>
<my:Id>2</my:Id>
<my:Date>20/04/2017 10:16:04</my:Date>
</my:Order>
</my:OrderList>
</my:Orders>
</my:Customer>
</my:Data>
Then I use Word's Xml Mapping pane to map this data to content control:
I simply duplicate the word file, and write new Xml data when generating new files.
This is working as expected. When I update the xml part, it reflects the data from my backend.
Thought, there's a case that does not works. If a customer has no order, the template content is kept in the document. The xml data is :
<my:Data
xmlns:my="https://schemas.mycorp.com">
<my:Customer>
<my:Details>
<my:Name>Some customer</my:Name>
</my:Details>
<my:Orders>
<my:Count>0</my:Count>
<my:OrderList>
</my:OrderList>
</my:Orders>
</my:Customer>
</my:Data>
(see the empty order list).
In Word, the xml pane reflects the correct data (meaning no Order node):
But as you can see, the template content is still here.
Basically, I'd like to hide the order list when there's no order (or at least an empty table).
How can I do that?
PS: If it can help, I uploaded the word and xml files, and a small PowerShell script that injects the data : repro.zip
Thanks for sharing your files so we can better help you.
I had a difficult time trying to solve your problem with your existing Word Content Controls, XML files and the PowerShell script that added the XML to the Word document. I found what seemed to be Microsoft's VSTO example solution to your problem, but I couldn't get this to work cleanly.
I was however able to write a simple C# console application that generates a Word file based on your XML data. The OpenXML code to generate the Word file was generated code from the Open XML Productivity Tool. I then added some logic to read your XML file and generate the second table rows dynamically depending on how many orders there are in the data. I have uploaded the code for you to use if you are interested in this solution. Note: The xml data file should be in c:\temp and the generated word files will be in c:\temp also.
Another added bonus to this solution is if you were to add all of the customer data into one XML file, the application will create separate word files in your temp directory like so:
customer_<name1>.docx
customer_<name2>.docx
customer_<name3>.docx
etc.
Here is the document generated from the first xml file
Here is the document generated from the second xml file with the empty row
Hope this helps.

Custom Search Results in REST MarkLogic

So new to MarkLogic am stuck and not finding the documentation of use. I know what i need to do, just do not know how to do it.
I have a keyvalue? search on my REST server which returns ML's standard search results and XML snippet. I want to create my own custom search result which will output a title element for my XML files.
I am aware that i need to create an XSLT transformation document and upload that to the server but do not know how to target ML's search function or how to write this out.
I have basic knowledge of XSLT, if i just created something that targets each files title using xPath will this work, or does ML require use of their custom functions?
I know its a bit broad, but hopefully someone can point steer me.
Sounds like you are talking about the GET /v1/keyvalue endpoint of MarkLogic REST API. Unfortunately that does not allow you to choose a transform. You can probably use GET /v1/search with a transform param instead though, using a structured query for an element value query. The docs contain a good syntax reference on that.
Docs on creating and managing transforms can be found here:
http://docs.marklogic.com/guide/rest-dev/transforms#chapter
HTH!
You can use extract-metadata in your search options with search:search or the /v1/search/ REST API endpoint to include the title element in a metadata element or JSON property in your results:
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
search:search(
"my query string",
<options xmlns="http://marklogic.com/appservices/search">
<extract-metadata>
<qname elem-ns="" elem-name="title"/>
</extract-metadata>
</options>)
If you need more flexibility, you specify a custom snippet implementation or a results decorator function in your search options.
Is this key-value or full text? For key-value you could use XPath. Any XPath that starts with / or // or fn:collection() or fn:doc() will search the entire database. You can search specific document(s) or collection(s) too.
For full text you'd probably want to use https://docs.marklogic.com/search:search - or possibly https://docs.marklogic.com/cts:search for really low-level control.
There's some example code using search:search from XSL at https://github.com/marklogic/RunDMC which might help. It doesn't use the REST API: it's a traditional form-submit web page. But the view/search.xsl code might give you some idea how to call the search API from XSLT.
That RunDMC code might also help you if you need to call XSL from XQuery: take a look at controller/transform.xqy.

Finding a download URL from the NuGet OData feed

What's the trick for deriving a download URL given an entry in the Packages table in the OData data set?
< content type="application/zip" src="SOME-URL" />
Under the <entry/> node, look for a <content/> node which contains 2 attributes type and src. The src attribute contains the download url. You could use LINQ to XML to get it. Seems easy, right? Oh, and remember to append an XNamespace to the XName when using LINQ to XML to query the nodes.