Why this xpath fails - xslt

I have the following xml file
<applications>
<application>
<forms>
<questions>
<first_name>
My Name
</first_name>
</questions>
</forms>
</application>
</applications>
First I have a for each loop which runs through all applications and assigns a variable app to a current application. Then I test each application like this:
<wr:if select="${app}/forms/questions/first_name" notEmpty="true">Print this if succeeded</wr:if>
I am trying to test if there is a text in first_name tag, but in the end I always have empty string, I guess my if does not succeed. Do you know if I made a mistake in my xpath?

Try to use text():
<wr:if select="${app}/forms/questions/first_name/text()" notEmpty="true">Print this if succeeded</wr:if>

Related

How to manipulate xml data in Oracle SOA suite?

<Employees manager="101" xmlns:ns1="http://www.example.org" xmlns="http://www.example.org">
<ns1:person ssn="101">
<ns1:firstName>Lakshminarayana</ns1:firstName>
<ns1:lastName>medikoda</ns1:lastName>
</ns1:person>
<ns1:person ssn="102">
<ns1:firstName>narasimha</ns1:firstName>
<ns1:lastName>mannepalli</ns1:lastName>
</ns1:person>
<ns1:person ssn="103">
<ns1:firstName>venu</ns1:firstName>
<ns1:lastName>ponakala</ns1:lastName>
</ns1:person>
</Employees>
I want to append new records and remove some records from this file in oracle soa
You should not be using XSLT to make this adjustment, you should be using the BPELX functions in an Assign activity.
To append a new record into the list you should be doing the following
bpelx:append
The bpelx:append extension in an assign activity enables a BPEL process to append the contents of one variable, expression, or XML fragment to another variable's contents.
<bpel:assign>
<bpelx:append>
<bpelx:from ... />
<bpelx:to ... />
</bpelx:append>
</bpel:assign>
The following example will show you how to implement this in your example.
<bpel:assign>
<bpelx:append>
<from variable="variableFrom"
query="variableFromQuery" />
<to variable="variableTo"
query="/ns1:Employees/ns1:person" />
</bpelx:append>
</bpel:assign>
To remove this from the queue you should
The bpelx:remove extension in an assign activity enables a BPEL process to remove a variable.
<bpel:assign>
<bpelx:remove>
<bpelx:target variable="variableName" part="Employee" query="query to match node you want to remove" />
</bpelx:remove>
</bpel:assign>

Ant pass specific string values from one file to another

I'm trying to configure autoincrement of version number in an Android aplication.
I've configured Ant tasks which make a checkout of the file then autoincrement the string with version value and then automatically do check-in in TFS system. So this test.properties file has this contetnt:
versionCode="1"
Autoincrement did this task:
<propertyfile file="${basedir}/src/test.properties">
<entry key="versionCode" value="1" type="int" operation="+" />
</propertyfile>
How would I configure replacement of the value of this string: android:versionCode="1", located in the target file androidmanifest.xml?
I suppose you can use the ReplaceRegExp task in Ant:
Directory-based task for replacing the occurrence of a given regular expression with a substitution pattern in a file or set of files.
It might look something like this:
<replaceregexp file="${src}/androidmanifest.xml"
match="android:versionCode="[0-9]+""
replace="android:versionCode="${versionCode}""
/>
The build.number property could be obtained by reading in the property file before running this task.
A solution with vanilla ant, no Ant addon needed, you may use a propertyfiletemplate that has =
f.e. named props.txt
...
android:versionCode=#versionCode#
...
and later on use the property ${versionCode} set by your workflow
and create a propertyfile from your template with copy + nested filterset =
<!-- somewhere set in your workflow maybe via userproperty -DversionCode=42 -->
<property name="versionCode" value="42"/>
...
<copy file="props.txt" todir="/some/path" overwrite="true">
<filterset>
<filter token="versionCode" value="${versionCode}"/>
</filterset>
</copy>
/some/path/props.txt will have =
...
android:versionCode=42
...
see Ant Manual on filtersets

Getting and displaying data from database with xforms on submission

I have a database with an xml document in it, and I want to display a transformed xml on my xforms page, when the submission is sent (I'm using orbeon forms).
My solution is, that on the submission my servlet gets the xml from the database, writes it into a file, xslt transforms the xml tree (when and how should I do the transformation?), but I don't know, how to display this file on the xforms page. Maybe the replace="instance" attribute in can help, but i don't know how.
Thanks!
Now, after Alessandro's advice, Im trying to use this xpl thing, but it doesn't work.
In the model:
<xforms:insert nodeset="instance('inst2')"
origin="xxforms:call-xpl('oxf:/resources/pipeline.xpl', 'data',
instance('inst1'), 'data')"/>
in pipeline.xpl:
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<p:param type="input" name="data"/>
<p:param type="output" name="data"/>
<p:processor name="oxf:xslt">
<p:input name="data" href="#data"/>
<p:input name="config" href="transform.xsl"/>
<p:output name="data" ref="data"/>
</p:processor>
My instance, that I want to transform is "complaint-instance", the transformed instance called "trf-instance", the pipeline.xpl file is in the same directory with my xforms page. My styesheet called customerToOperator.xsl. What's wrong in my code?
I just noticed, the note: "If you are using separate deployment, the service and XSLT transformation must be present in the Orbeon WAR file, instead of within your application."
Ehm... Where should I put these files?
my app in details:
a) an xforms page, with 2 instances:
<instance id='inst1'>
<name>
<lastname/>
<firstname/>
</name>
</instance>
<instance id='inst2'>
<fname>
<fullname/>
</fname>
</instance>
I got 2 input fields, referenced on name/lastname and name/firstname.
I have an xforms:insert node, described above, and an xforms:submission node:
<xforms:submission
id="save-submission"
ref="instance('inst2')"
action="/my-servlet"
method="post"
replace="none">
I added 2 files to orbeon/WEB-INF/resources, the pipeline.xpl, (described above) and transform.xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<fname>
<fullname>
<xsl:value-of select="name/firstname"/>
<xsl:value-of select="name/lastname"/>
</fullname>
</fname>
</xsl:template>
</xsl:stylesheet>
And I have a servlet, which writes the posted instance on the console (now it writes inst2 on the console, but without the user input data, only the nodes...)
A really need to fix this...
Thanks again!
To get the XML from a database (relational or not) and apply a transformation, instead of writing my own servlet, I would use an XPL pipeline, and map this pipeline to a URL through the page flow. Now you have a service that answers to an HTTP request and returns XML. To call the service from XForms, you use an <xforms:submission replace="instance">. You end up with the XML in an instance, and you can display it with something like: <xforms:output value="saxon:serialize(instance(), 'xml')"/>.
In all cases (including separate deployment), the pipeline and XSLT file must be in the "resources". Usually, this means the WEB-INF/resources of the Orbeon's web app. But you can also do more fancy things by setting up the Orbeon resource manager to also use other directories on disk.

Exclude nodes based on attribute wildcard in XSL node selection

Using cruisecontrol for continuous integration, I have some annoyances with Weblogic Ant tasks and how they think that server debug information are warnings rather than debug, so are shown in my build report emails. The XML output from cruise is similar to:
<cruisecontrol>
<build>
<target name="compile-xxx">
<task name="xxx" />
</target>
<target name="xxx.weblogic">
<task name="wldeploy">
<message priority="warn">Message which isn't really a warning"</message>
</task>
</target>
</build>
</cruisecontrol>
In the cruisecontrol XSL template the current selection for the task list is:
<xsl:variable name="tasklist" select="/cruisecontrol/build//target/task"/>
What I would like is something which selects the tasklist in the same way, but doesn't include any target nodes which have the attribute name="*weblogic" where * is a wildcard. I have tried
<xsl:variable name="tasklist" select="/cruisecontrol/build//target[#name!='*weblogic']/task"/>
but this doesn't seem to have worked. I'm not an expert with XSLT, and just want to get this fixed so I can carry on the real development of the project. Any help is much appreciated.
In the cruisecontrol XSL template the
current selection for the task list
is:
<xsl:variable name="tasklist" select="/cruisecontrol/build//target/task"/>
What I would like is something which
selects the tasklist in the same way,
but doesn't include any target nodes
which have the attribute
name="*weblogic" where * is a wildcard
Use:
/cruisecontrol/build
//target
[not(substring(#name, string-length(#name)-7)
= 'weblogic'
)
]/task

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.