Exclude nodes based on attribute wildcard in XSL node selection - xslt

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

Related

how can I deeplink an app from Google Assistant?

I'm creating a dialogflow agent integrated with Google Assistant.
What I'd like to do is to open an app (my app) when a proper intent is matched. I've seen that actions like Youtube, Spotify etc. are able to do that, for example I can tell the Youtube action "search for cats video" and the Youtube app will open with a list of cats videos.
I tried to use the DeepLink class but I then noticed it's deprecated.
DeepLink class
Is there any way you can suggest me to do this?
Thanks in advance
I think you are looking for App Actions. Here are the steps you need to follow:
Find the right built-in intent. actions.intent.OPEN_APP_FEATURE should be the right one for you.
Create and update actions.xml. It should look like
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a sample actions.xml -->
<actions>
<action intentName="actions.intent.OPEN_APP_FEATURE">
<!-- Use url from inventory match for deep link fulfillment -->
<fulfillment urlTemplate="{#url}" />
<!-- Define parameters with inventories here -->
<parameter name="feature">
<entity-set-reference entitySetId="featureParamEntitySet" />
</parameter>
</action>
<entity-set entitySetId="featureParamEntitySet">
<!-- Provide a URL per entity -->
<entity url="myapp://deeplink/one" name="featureParam_one" alternateName="#array/featureParam_one_synonyms" />
<entity url="myapp://deeplink/two" name="featureParam_two" alternateName="#array/featureParam_two_synonyms" />
</entity-set>
</actions>

XMLNS attribute removed by Slow Cheetah transformation

I'm trying to use Slow Cheetah to transform a Windows scheduled task config file. I'm simply trying to add "repetition" node information, like so:
ORIGINAL:
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2013-01-02T09:32:12.2196371</Date>
<Author>xxx</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2013-01-10T01:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
.....
</Task>
REQUIRED, ADDITIONAL XML
<CalendarTrigger>
<Repetition>
<Interval>PT300S</Interval>
</Repetition>
</CalendarTrigger>
To do this, I have the following transformation file:
<?xml version="1.0" encoding="utf-16" ?>
<Task version="1.2">
<Triggers>
<CalendarTrigger xdt:Transform="Insert">
<Repetition>
<Interval>PT300S</Interval>
</Repetition>
</CalendarTrigger>
</Triggers>
</Task>
The problem I'm having is that all attributes outside of the CalendarTrigger node are removed (and therefore making the resultant transformation config an invalid scheduled task format).
I have tried adding
xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="SetAttributes" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"
to the Task node, but the attribute is then generated at CalendarTrigger level (and I cannot put this attribute on the original, because I then get "No element in the source document matches '/Task/Triggers' ").
Any pointers?
UPDATE:
The problem seems to be isolated to the xmlns attribute; if I try to include this in the 'Task' node of the original, I get "No element in the source document matches '/Task/Triggers'" - BUT changing this attribute to 'xmlns2' works fine and produces exactly what I need (albeit with an 'xmlns2' attribute!). Is this a known limitation of Slow Cheetah? Anyone know of a potential work-around?
That's because your xdt:Transform="Insert" is one level to high.
This should work:
<?xml version="1.0" encoding="utf-16" ?>
<Task xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<Triggers>
<CalendarTrigger>
<Repetition xdt:Transform="Insert">
<Interval>PT300S</Interval>
</Repetition>
</CalendarTrigger>
</Triggers>
</Task>

copy complexType to message in BPEL

I am using Apache ODE to write some simple BPEL's to connect 2 web services.
One of the WSDL files of my two services contains this complex type:
<types>
<t:schema targetNamespace="http://ws.panos.com/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<t:complexType name="myObject">
<t:sequence>
<t:element minOccurs="0" name="str" type="t:string" />
</t:sequence>
</t:complexType>
</t:schema>
How do I make a copy from a service return message (which is just a xsd:string) to the input of a message (inside "str" of type "myObject"?
I have tried to do this, but doesnt seem to work:
<assign name="assign_2">
<copy>
<from variable="wsA_output" part="return"/>
<to variable="wsC_input" part="arg0" query="/arg0/str"/>
</copy>
I always get a null string transfered. Help much appreciated.
The to-spec <to variable="..." part="..." query="..."/> is not valid in BPEL 1.1 nor BPEL 2.0. The correct equivalent expression is: <to>$wsC_input.arg0/arg0/str</to> or <to variable="wsC_input" part="arg0"><query>/arg0/str</query></to>. Please make also sure that you initialize the variable before assigning values to nested structures.
Just found the mistake. You are right, we need to query in order to find the field like this:
<assign name="assign_2">
<copy>
<from variable="wsA_output" part="return"/>
<to>$wsC_input.message/arg0/str</to>
</copy>
</assign>
Also, we need to initialize the variable like this:
<assign name="assign_init">
<copy>
<from>
<literal><arg0><str xmlns="">nothing</str></arg0></literal>
</from>
<to variable="wsC_input" part="arg0"></to>
</copy>
</assign>
The xmlns="" is needed when the default namespace in your bpel is different that the namespace in the receiving web service.
I am just writing these down for future reference :)
Again, thanks for you your answer.
Some links that could also help other people:
http://ode.apache.org/faq.html
http://jee-bpel-soa.blogspot.com/2009/08/manipulating-ws-bpel-variables-and.html

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

Ant regexp mapper: Reading patterns from a file?

I would like to write a generic Ant build script with a <copy> task that could optionally rename files based on regexps. A nested <regexpmapper> would load the renaming patterns from a project-specific properties files if it exists.
Has someone already done this or do I have to write an own mapper?
Here's an example of how you might do this.
Project properties file proj_props.txt contains:
use.filter=regexp.mapper
from.regexp=(.*)_test(.*)
to.regexp=\\1\\2
(Note the escapes \ in the to string.)
Buildfile:
<property file="proj_props.txt" />
<!-- filter for regexp -->
<filtermapper id="regexp.mapper">
<tokenfilter>
<replaceregex pattern="${from.regexp}"
replace="${to.regexp}" />
</tokenfilter>
</filtermapper>
<!-- identity filter, used when no regexp needed -->
<filtermapper id="identity.mapper" />
<!-- decide which filter to use -->
<condition property="chosen.mapper"
value="regexp.mapper" else="identity.mapper">
<isset property="use.filter" />
</condition>
<copy todir="...">
<fileset>
...
</fileset>
<filtermapper refid="${chosen.mapper}" />
</copy>
You define a couple of filtermapper instances, one that carries out a regexp replace based on properties from the project properties file, the other that does nothing. The use.filter property decides which gets chosen. If the project properties file doesn't exist use.filter would not be set, so the 'do-nothing' identity filtermapper will be used.
Note that this only works when using nested resources in the copy task. If you only have one file to copy, and use <copy file="...", the filtermapper is ignored.