MSBuild XMLUpdate Question - msbuild

I am using the XMLUpdate to update an xml formatted file in MSBuild. It updates fine but adds <?xml version="1.0" encoding="utf-8"?> at the top after update. Here is my statement that updates
<Import Project="C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<XmlUpdate XmlFileName="$(AppName).alx" Xpath="/loader/application/version" Value="$(AppVersion)" />
Is it possible to update without the xml element at the top?
Thanks
Ponnu

The <?xml ...> is more of a descriptor than a real XML element. It describes your document and, for example defines the encoding. It won't interfere with your existing elements. I think it is even a standard feature of a XML document (but I don't have the specs handy)

Related

How to set request body params in karate for soap request [duplicate]

I have the following xml:
<?xml version="1.0" encoding="utf-8"?>
<request>
<head>
<session-id>none</session-id>
</head>
<service name="test">
<function name="testFunc">
<guids>
<guid>#guid#</guid>
<guid>#guid#</guid>
</guids>
</function>
</service>
</request>
I have 2 test cases:
i want to test with single guid.
I want to test with 2 guids.
I created 2 separate xml for both the test cases and it worked.
The question here is how can i use a common xml?
Also i tried using remove but how do i remove single guid from the xml?
There is something called "embedded expressions" in Karate. Read the docs: https://github.com/intuit/karate#embedded-expressions
Example:
* def guids = <guids><guid>one</guid><guid>two</guid></guids>
* def body = <root>#(guids)</root>
Also refer this file, it has a lot of other examples and ideas for XML data-driven tests: xml.feature.

How to execute a CustomSqlChange manually

I'm writing a CustomSqlChange for the first time and want to test the outcome by running it on my current database. Of course I could start up the application and execute all change sets via liquibase (including the one that executes my CustomSqlChange), but that takes a lot of time.
Is there a way to manually execute the java class implementing CustomSqlChange from my IDE (IntelliJ) as if it would be from liquibase? Could one maybe even debug that execution?
You can create a separate changelog file, where only your's custom change will be included. Point Liquibase to use it instead of base one. This will give you ability to debug it as well.
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog .....>
<changeSet id="custom-change" author="author" runOnChange="true" >
<customChange param="..." />
</changeSet>
</databaseChangeLog>

Unitils dataset and modified dates

Any ideas how this can be done with Unitils dbunit?
Date relative to current in the DBUnit dataset
The problem is that the [create_date]-placeholder is not recognized in #Dataset.
A simple solution might be to just use placeholders in your xml dataset, eg.
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<user userName="jdoe" name="doe" firstname="john" lastLogin="{YESTERDAY}" />
<user userName="jdoe" name="doe" firstname="jane" lastLogin="{A_WEEK_AGO}" />
</dataset>
and do some post-processing(replace the placeholders with the calculated values) before you run your tests. When you are using Maven, you could then first execute the post-processing, (fill in the values in the xml-template-dataset, copy the filled-in-xml-dataset to the correct folder), before any tests are executed.

xml namespace and xml literals

I'm experimenting with xml literals in vb.net and there's something I don't get. Here's a small sample that illustrates the problem. I'm adding two PropertyGroup nodes to an empty Visual Studio project. The first one is added as xml literal, the second as new XElement:
Imports <xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Module MyModule
Sub Main()
Dim vbproj = <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
vbproj.Root.Add(<PropertyGroup></PropertyGroup>)
Dim xNameSpace As XNamespace = "http://schemas.microsoft.com/developer/msbuild/2003"
vbproj.Root.Add(New XElement(xNameSpace + "PropertyGroup"))
Console.WriteLine(vbproj)
End Module
This code writes the following output:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></PropertyGroup>
<PropertyGroup />
</Project>
As you can see, the first PropertyGroup node contains a redundant xmlns declaration. Why is that, and can it be avoided?
This appears to be by design, based on reading the MSDN page for Imports Statement (XML Namespace).
The simplest way to avoid it is by using the SaveOptions.OmitDuplicateNamespaces enumeration, which is available in .NET 4.0:
vbproj.AddAnnotation(SaveOptions.OmitDuplicateNamespaces)
If .NET 4.0 isn't an option then you might consider cleaning up the namespaces as shown in these two blog posts:
Cleaning up your XML literal namespaces - provides an extension method to be used on each XElement to remove the namespace.
More on XML Namespaces in VB.... - provides an extension method that can be used on the root node and remove namespaces from children items by specifying True for the second parameter.

Docbook publishing for different target audiences

I like to have one docbook xml document that has content for several target audiences. Is there a filter that enables me to filter out the stuff only needed for "advanced" users?
The level attribute is invented by me to express what I have in mind.
<?xml version="1.0"?>
<book>
<title lang="en">Documentation</title>
<chapter id="introduction" level="advanced">
<title>Introduction for advanced users</title>
</chapter>
<chapter id="introduction" level="basic">
<title>Introduction for basic users</title>
</chapter>
<chapter id="ch1">
<para level="basic">Just press the button</para>
<para level="advanced">
Go to preferences to set your
needs and then start the process
by pressing the button.
</para>
</chapter>
</book>
DocBook does not have a level attribute. Perhaps you meant userlevel?
If you are using the DocBook XSL stylesheets to transform your documents, they have built-in support for profiling (conditional text). To use it you need to
use the profiling-enabled version of the stylesheet (e.g. use html/profile-docbook.xsl instead of the usual html/docbook.xsl), and
specify the attribute values you want to profile on via a parameter (e.g. set profile.userlevel to basic).
Chapter 26 of Bob Stayton's DocBook XSL: The Complete Guide has all the details.
Two ways, off the top of my head:
Write a quick script that takes the level as a parameter and, using XPath or regular expressions, that only spits out the XML you want.
Write an XSLT transformation that will spit out the XML you want.
(2) is cleaner, but (1) is probably faster to write up.