0 xsd:anyURI using esql.IBM Integration Bus - ibm-integration-bus

<payload xsi:type="ns787:SomeRequest" xmlns:ns787="http://ws.abc.efg.com"/>
I'm working with IIB v10.0.0.7. I'd like to define one of the XML elements to be of type xsd:anyURI using esql. output should be like given above:

I assume that you are asking about the xsi:type attribute. The XMLNSC parser does not automatically populate the namespace prefix in the value of the xsi:type attribute - you must set the entire value (prefix:localName) as a literal text string.
DECLARE namespace787 NAMESPACE 'http://ws.abc.efg.com';
DECLARE namespaceXSI NAMESPACE 'http://www.w3.org/2001/XMLSchema-instance';
CREATE LASTCHILD OF OutputRoot.XMLNSC.payload TYPE XMLNSC.Attribute NAMESPACE namespaceXSI NAME 'type' VALUE 'ns787:SomeRequest';
CREATE LASTCHILD OF OutputRoot.XMLNSC.payload TYPE XMLNSC.NamespaceDecl NAME 'xmlns:ns787' VALUE namespace787;
or, if you prefer using SET instead of CREATE:
...
SET OutputRoot.XMLNSC.payload.(XMLNSC.Attribute)namespaceXSI:type = namespaceXSI;
SET OutputRoot.XMLNSC.payload.(XMLNSC.NamespaceDecl)xmlns:ns787 = namespace787;
If you are still stuck then you may find this technique useful: How to create a complex object in ESQL

Related

GraphQL type containing a finite set of string values

In typescript I can write:
type T = 'some words' | 'some other words' | ...
Is it possible to define such a type in GraphQL schema?
I have a downstream service that returns a set of values, some containing blanks and I would like to have a type restricted to only those values.
You can define a custom scalar that only allows your set of values.
In the absence of spaces you could also use an enum.

Fetch value from XML using dynamic tag in ESQL

I have an xml
<family>
<child_one>ROY</child_one>
<child_two>VIC</child_two>
</family>
I want to fetch the value from the XML based on the dynamic tag in ESQL. I have tried like this
SET dynamicTag = 'child_'||num;
SET value = InputRoot.XMLNSC.parent.(XML.Element)dynamicTag;
Here num is the value received from the input it can be one or two. The result should be value = ROY if num is one and value is VIC if num is two.
The chapter ESQL field reference overview describes this use case:
Because the names of the fields appear in the ESQL program, they must be known when the program is written. This limitation can be avoided by using the alternative syntax that uses braces ( { ... } ).
So can change your code like this:
SET value = InputRoot.XMLNSC.parent.(XMLNSC.Element){dynamicTag};
Notice the change of the element type as well, see comment of #kimbert.

XQuery/Xpath referring to xml elements with no namespace, in a namespace environment

In Xquery 3.1 (under eXist-DB 4.7) I receive xml data like this, with no namespace:
<edit-request id="TC9999">
<title-collection>foocolltitle</title-collection>
<title-exempla>fooextitle</title-exempla>
<title-short>fooshorttitle</title-short>
</edit-request>
This is assigned to a variable $content and this statement:
let $collid := $content/edit-request/#id
...correctly returns: TC9999
Now, I need to actually transform all the data in $content into a TEI xml document.
I first need to get some info from an existing TEI file, so I assigned another variable:
let $oldcontent := doc(concat($globalvar:URIdata,$collid,"/",$collid,".xml"))
And then I create the new TEI document, referring to both $content and $oldcontent:
let $xml := <listBibl xmlns="http://www.tei-c.org/ns/1.0"
type="collection"
xml:id="{$collid}">
<bibl>
<idno type="old_sql_id">{$oldcontent//tei:idno[#type="old_sql_id"]/text()}</idno>
<title type="collection">{$content//title-exempla/text()}</title>
</bibl>
</listBibl>
The references to the TEI namespace in $oldcontent come through, but to my surprise the references to $content (no namespace) don't show up:
<listBibl xmlns="http://www.tei-c.org/ns/1.0"
type="collection"
xml:id="TC9999">
<bibl>
<idno type="old_sql_id">1</idno>
<title type="collection"/>
</bibl>
</listBibl>
The question is: how do I refer to the non-namespace elements in $content in the context of let $xml=...?
Nb: the Xquery document has a declaration at the top (as it is the principle namespace of virtually all the documents):
declare namespace tei = "http://www.tei-c.org/ns/1.0";
In essence you are asking how to write an XPath expression to select nodes in an empty namespace in a context where the default element namespace is non-empty. One of the most direct solutions is to use the "URI plus local-name syntax" for writing QNames. Here is an example:
xquery version "3.1";
let $x := <x><y>Jbrehr</y></x>
return
<p xmlns="foo">Hey there,
{ $x/Q{}y => string() }!</p>
If instead of $x/Q{}y the example had used the more common form of the path expression, $x/y, its result would have been an empty sequence, since the local name y used to select the <y> element specifies no namespace and thus inherits the foo element namespace from its context. By using the "URI plus local-name syntax", though, we are able to specify the empty namespace we are looking for.
For more information on this, see the XPath 3.1 specification's discussion of expanded QNames: https://www.w3.org/TR/xpath-31/#doc-xpath31-EQName.

How can I compare strings case sensitive in xforms:select1 ref attribute?

I have to provide the ref attribute value in an xf:select1. I need to select names of properties only if they are present in the supportedProperties instance which can be done with the following:
<xf:select1
ref="
instance('properties')/property[
name = instance('supportedProperties')/property/name
]/name">
However, the problem is that supportedProperties can contain names which are in capital letters. Assuming we cannot change the instance, is there a way we can do a case sensitive comparison?
Tried to use the lower-case() XPath function as follows but it didn't work:
<xf:select1
ref="
instance('properties')/property[
name = instance('supportedProperties')/property/name
]/lower-case(name)">
Assuming you are using XPath 2, you can write:
<xf:select1
ref="
instance('properties')/property[
name = instance('supportedProperties')/property/name/lower-case(.)
]/name">
What this does is that the lower-case(.) function applies to all elements in the sequence returned by instance('supportedProperties')/property/name.
You can also write it:
<xf:select1
ref="
instance('properties')/property[
name = (
for $name in instance('supportedProperties')/property/name
return lower-case($name)
)
]/name">

jxls forEach tag : how to define local variables?

Can we define local variables in jxls which can be used to set an incrementing count for a column.
For eg: Consider the following
<jx:forEach items="${myList}" var="myVar">
-- i need to define a local integer variable here which will have an initial value as 0
-- and i will increment it and display in the output xls's first column
</jx:forEach>
Basically my requirement is to have somekind of local variable declaration in jxls code which i would increment and display in xml.
Any other alternatives are welcome.
Regards,
Rahul
jx:forEach tag support varStatus attribute which defines a name of loop status object which will be passed into bean context for each iteration. The loop status object is an instance of LoopStatus class which has single 'index' property identifying the index of the current item in the collection being iterated
<jx:forEach items="${employees}" var="employee" varStatus="status">
| ${status.index} | ${employee.name} | ${employee.payment} | ${employee.bonus}
</jx:forEach>
Figured it out.... We can use <jx:out expr="hssfRow.getRowNum()" /> in the column where we want to display the numbering. We can keep the above piece of code inside <jx:forEach items="${myList}" var="myVar"> tag

Resources