I'm currently authoring a new NuGet package, but I can't get the app.config.install.xdt file right (which is the xml file that transforms app.config to suit the installed package).
The problem is inserting a <configSections> section in app.config as the first child - but only in case it is missing!
It MUST be the first child, or the application will fail with an exception (Microsoft enforcement).
If I just use the regular “InsertIfMissing” transform, the insertion takes place after any existing children, so that seems a no-go.
What can I do to solve my problem?
I've had exactly the same problem and solved it this way:
<configSections xdt:Transform="InsertBefore(/configuration/*[1])" />
<configSections xdt:Locator="XPath(/configuration/configSections[last()])">
do_your_stuff_with_sections_here...
</configSections>
<configSections xdt:Transform="RemoveAll" xdt:Locator="Condition(count(*)=0)" />
The first line unconditionally creates the node as first child:
<configSections xdt:Transform="InsertBefore(/configuration/*[1])" />
The second line makes sure all your edits are done to the last configSections node, which is de correct node if it already existed…
<configSections xdt:Locator="XPath(/configuration/configSections[last()])">
After the transforms you do in de configSections block, you enter a command that removes all empty configSections nodes… (last line)
<configSections xdt:Transform="RemoveAll" xdt:Locator="Condition(count(*)=0)" />
How to insert as first child in app.config
You can utilize the attribute xdt:Transform="InsertBefore" to insert a new element in the section but before the any other element, like:
<configSections xdt:Transform="InsertBefore(/configuration/*[1])" />
Certificate: XDT Transform: InsertBefore - Locator Condition is ignored
And see How to use XDT in NuGet - Examples and Facts for some more details.
Hope this helps.
I was looking for the solution as well...
<configSections xdt:Transform="Remove" />
<configSections xdt:Transform="InsertBefore(/configuration/*[1])">
Related
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>
<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>
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
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.
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