URI of same element in two documents - stylesheet - xslt

I have two xml config files that has same elements. I want to compare if the uri is same for them. If they are different I need to print the element name.
Doc1 :
<config>
<google>
<url>google.com/api/getcoordinates</url>
</google>
<ranst>
<url>http://ranst.com/getranst</url>
<ranst>
</config>
doc2:
<config>
<google>
<url>google.com/api/getlocationcordinates</url>
</google>
<akamai>
<url>http://akamai.com/redirectlocation/eastregion</url>
<akamai>
</config>
Document1 and document2 has google in common , but the uri's are different. So I want to call this out. How can I do this using XSLT ?
Thanks.

Related

Addressing an xml value in enrich Mediator

I want to address an xml value in the Xpath field within the enrich mediator in order to customize an API response. My xml input is as follow:
<member>
<name>ABC</name>
</value>1</value>
</member>
I tried to access the 'ABC' value by using this code:
$body//member[#name='ABC']
but it does not work for me.
First of all your XML input is not valid. There is no opening value tag but two closing.
Can you try //member/name/text(),this worked für me.If its not working,then maybe you need to add the namespaces.
Hope that helps.

XSLT copy from external document

In XSLT 2.0 I am transforming a tei-xml document into HTML. In that transformationI need content from another document: I want to copy/transform a small set of nodes from the second document into the HTML output.
While processing the principal tei document I get the id and assign it to a variable:
<xsl:variable name="licenseid" select="./replace(#corresp,'#','')"/>
Then I go out to the other document and fetch the node using the variable, with the returned node assigned to a variable:
<xsl:variable name="licenseloc" select="doc(concat($somepath,'includes_sourcedesc.xml'))//tei:list[#type='copyright_type']/tei:item[#xml:id=$licenseid]"/>
This node I obtain looks like this:
<list type="copyright_type">
<item xml:id="copyright-cc-by-nc-sa-4.0">
<desc xml:lang="en">This work is made by available the author under the
<ref target="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</ref>.</desc>
</item>
</list>
And I want to transform it (from desc) to this:
<span>This work is made by available by the author under the
<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</a>.</span>
If this were in my 'current' tei document I would handle it through templates, but I'm unsure how to copy and transform the nested layers from within a different 'current' document.

Regarding <Results> Element/propery/Tag/Function in DataPower xslt

This may be somewhat naive but I am quite struck on the issue
There is a specific <result> element in DataPower and when calling through xslt we have somewhat following format(which I discovered in some forums)--
<results mode="require-all" multiple-outputs="true" transactional="true" retry-interval="100" asynchronous="false">
<url input="var://the_request_SOAP_Format"asynchronous="true">https://XXXXXXX</url>
now in this (url input) is the request which needs to be send and (https://XXXXXXX) is the specified backend where it needs to be sent
Now I have some authentication headers(httpHeaders) also which I need to send without which I will get Authorization error
<xsl:variable name="httpHeaders">
<header name="Content-Type">application/json</header>
<header name="Authorization">
<xsl:value-of select="concat('Bearer ',$some_sessionID)"/>
</header>
</xsl:variable>
Is this possible to add these 'httpHeaders' in the result mode element/Tab property
Thanks
I am not exactly sure what you are trying to achieve but adding http headers for the response (backside) you do with:
<dp:set-http-response-header name="'HeaderName'" value="$httpHeaders"/>
or
<dp:set-http-request-header name="'HeaderName'" value="$httpHeaders"/>
The <results> is the collection of data that the Processing Policy will output as Payload for the Request/Response and won't contain headers. You shouldn't try to alter the <results> object!
The "results-doc" method of calling backends is quite powerful, but I'm not sure from your question if you fully understand it. The url/#input attribute needs to be a DataPower context:
<url input="var://context/mycontext" ...
To associate headers with that context, you should do something like this for each header you need:
<dp:set-variable
name="'var://context/mycontext/_extension/header/Content-Type'"
value="'application/json'"/>
(This would be done in your XSLT code, separate from creating the "results" document, but before you use a Results Action to execute.)

Loading xml in non-binary tree

I have created non-binary tree in order to load xml data in it and be used later for dialogue system.I want to implement the dialogue systems like in fallout where every answer can contain 4 different nodes with another answers.So far i created xml with the sentences
<Dialogue>
<Node>Hello,what do you want?</Node>
<Leaf>Nothing</Leaf>
<Leaf>Really?</Leaf>
<Branch>
<Node>Really?</Node>
<Leaf>Yes></Leaf>
<Branch>
<Node>No</Node>
<Leaf>Why not?</Leaf>
</Branch>
</Branch>
</Dialogue>
here node in the tree in c++ is represented as parent Leafs are child and below first branch node is child of the upper node.I find difficultis to load the xml data in tree with this structure so do you have ideas for better structures?
With your current structure of XML, you'll find it tricky to implement this, I'll suggest one option..
<Dialogue>
<Node id="root">
<Prompt>Hello,what do you want?</Prompt>
<Response>
<match>Nothing</match>
<Branch node_id="nothing"/>
</Response>
: <!-- more Response nodes -->
</Node>
<Node id="nothing">
<Prompt>Really?</Prompt>
<Response>
<match>Yes</match>
<Branch node_id="nothing.yes"/>
</Response>
<Response>
<match>Actually...</match>
<Branch node_id="nothing.actually"/>
</Response>
</Node>
<Node id="nothing.yes">
<Prompt>Why not?</Prompt>
: <!-- Response Nodes -->
</Node>
<Node id="nothing.actually">
<Prompt>Okay, what then?</Prompt>
: <!-- Response Nodes -->
</Node>
</Dialogue>
In reality, with this type of data, you need a map to store each "Node", where a Node is a prompt with a set of responses (the key to the map is the id of Node - which you have to guarantee as being unique. Depending on which response matches, you can then then find the node in the map and hand control to that etc. Probably a little easier to deal with than a tree? Also give you the possibility of re-using states... NOTE: the XML above is really verbose, you can trim it down with attributes, my intention was to simply get the idea across...
It's an option to consider I guess...

How do I rename a file using the SharePoint web services?

I have a custom definition for a document library and I am trying to rename documents within the library using only the out of the box web services. Having defined a view with the "Name" field supplied and trying the "LinkFilename", my calls to rename a file are respectively returning a failure or ignoring the new value.
How do I rename a file using the SharePoint web services?
Use the Lists.UpdateListItems web method. The XML request should look like:
<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0">
<Method ID="1" Cmd="Update">
<!-- List item ID of document -->
<Field Name="ID">2</Field>
<!-- Full URL to document -->
<Field Name="FileRef">http://Server/FullUrl/File.doc</Field>
<!-- New filename -->
<Field Name="BaseName">NewName</Field>
</Method>
</Batch>
You should be able to use UpdateListItems. Here's an example.
Per comment: So the actual question is "how do I call a web service?" Take a look a this example. Some more good walkthroughs here.