How to tell Liquibase to ignore a db.changelog*.xml? - unit-testing

I would like liquibase to create a set of unit testing functions ONLY if the database is being created in a DEV environment.
I know I could create a "changeset" tag with a "context" attribute for every unit test function but I'd like to avoid that if possible.
What would be ideal is using "context" with the "includeAll" tag, like:
<includeAll path="./sql/UnitTest/" context="dev" />
but sadly that is not supported.
OR since I have several changelogs:
db.changelog.xml
include db.changelog-tables.xml
include db.changelog-functions.xml
...
include db.changelog-unit_test_functions.xml
If I could tell LiquiBase to skip running "db.changelog-unit_test_functions.xml" based on a command line parameter that would also work.
However, the "context" attribute is not allowed in the "include" element.
<include file="./sql/db.changelog-unit-test.xml" context="dev" />
I tried to attach a "preconditions" test to db.changelog-unit-test.xml but that fails ALL db.changelogs execution.
Does anyone have any clever ideas on how I can avoid writing a granular db.changelog-unit-test.xml?
Thanks!

Context in include or includeAll is working from 3.5
Pay attention to your xsd definition in your file - you need to have at lease http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd there, otherwise your file will not be validate even when running version newer then 3.5

Related

How to break caching on exist-db of included XSLs in Transform

I have a large set of XSLs that we recently went through and implemented a shared XSL template with common bits. We included an xsl:include in all the main XSLs now to pull these in. We had no issues at first until we started to make changes to the shared XSL.
For information, the whole system is web based, calling queries to dynamically format documents in the database given different XSLs through XSL FO and RenderX.
The main transform is:
let $fo := util:expand(transform:transform($articles, doc("/db/Customer/data/edit/xsl/Custbatch.xsl"), $parameters))
That XSL (Custbatch.xsl) has:
<xsl:include href="Custshared.v1.xsl"/>
If we make an edit to "Custshared.v1.xsl" is not reflected in the result because it is obvious that "Custshared.v1.xsl" is being cached and used. We know this because as you can see the name now includes "v1". If we make a change and change all the references say from v1 to v2, it all works. But this seems a bit ridiculous as that means we have to change the 18 XSLs that include this XSL or do something silly like restart the database.
So, what am I missing in the setup or controller.xql (which has the following on all not matched paths), to get things not to cache. I assume that is all internal so this setting likely does not matter. Is there some other setting in the config that does?
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="no"/>
</dispatch>
In reading the document here: http://exist-db.org/exist/apps/doc/xsl-transform.xml, it states:
"The stylesheet will be compiled into a template using the standard Java APIs (javax.xml.transform). The template is shared between all instances of the function and will only be reloaded if modified since its last invocation."
However, if I change an included XSL, it is not being used.
Update #1
I even went as far as creating a query that returns the XSL that is included, then I use:
<xsl:include href="http://localhost/get-include-xsl.xq"/>
This does work as formatting is not broken, but changing the underlying XSL yields the same result. So even that Xquery result is cached.
Update #2
And yes, through some simple test all is proven.
If I make any change to the root template (like add a meaningless space) and run, it does include the changes made in the include. If I only change the included XSL, no changes happen.
So lacking anything else, we could always write a Xquery that basically touches all the main templates after a change is made to the include template. Seems so wrong as a workaround.
Update #3
So the workaround we are currently using is that we have an unused "variable" in the XSL (version) and when we update the shared template, we execute that query which basically updates the value in that variable. At least it's only one XQuery and maybe we should attach to a trigger.
There is a setting in $exist-db-root$/conf.xml for the XSL transformer where you can turn off caching: <transformer class="net.sf.saxon.TransformerFactoryImpl" caching="no"> (The default is 'yes')

How to prevent XSLT message function to emit "Warning!"?

I am using ant's xslt-task plus a suitable XSLT script to remove certain nodes from XML documents that we are generating. To get some feedback during processing I added a few message-statements to the script. These work all fine, except that ALL emitted messages have a ": Warning!" prefix. Since the messages are informative only I want/need to get rid of these Warning-prefix to prevent alerting the user who might otherwise think that something is not OK.
How can I avoid that prefix? The XSLT message function seems to have no other option than 'terminate="yes"|"no". Can one somehow control that message prefix? And if so: how?
I am using the default xslt task built into ant, i.e. my target reads:
<xslt in="${source.xml}" out="${output.xml}" style="${stylesheet.xsl}" processor="trax">
</xslt>
with the misc. properties set to point to the appropriate locations. I found that command in some other stack-overflow append.
My ant version reads:
C:\Users\mmo>ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
I think you're probably using the default Xalan processor, and I'm afraid I can't advise you whether/how its xsl:message processing can be customized.
If you were to switch to using Saxon you would not only get the benefit of doubled productivity by use of XSLT 2.0 instead of 1.0, but you would also get (a) an interface for customising xsl:message output, and (b) membership of an active user community that can answer questions like this.
(Actually, now I think about it, I seem to recall that with Xalan, xsl:message output is sent to the warning() method of the registered ErrorListener, so if you don't want to switch you could try and write an ErrorListener.)

How do I skip a tests file if it is run on systems with go 1.4 and below?

I have a file containing some tests that should be run on Go 1.5+.
I am able to get the Go runtime version using runtime.Version() and doing various comparisons.
However, the test file imports golang.org/x/net/http2. The http2 package requires request.Cancel() from net/http, but that is only available on Go 1.5+.
That causes these errors in my CI environment causing the build to fail:
../../../golang.org/x/net/http2/transport.go:214: req.Cancel undefined (type *http.Request has no field or method Cancel)
../../../golang.org/x/net/http2/transport.go:218: req.Cancel undefined (type *http.Request has no field or method Cancel)
../../../golang.org/x/net/http2/transport.go:777: req.Cancel undefined (type *http.Request has no field or method Cancel)
I tried adding // +build go1.5 to the top of the file, but it didn't work.
Is there anyway I can limit a unit test file so that it is built and tested only on Go 1.5+ systems?
The build constraints is the proper way to do it.
But note that your error messages refer to the http2 package which was added in Go 1.6, so you need at least go1.6 build constraint.
The build constraint
// +build go1.5
Will cause the file to be compiled with Go 1.5 and onward. So if you want your test file to only compile and run with Go 1.6 and above, then use
// +build go1.6
Also don't forget that:
Constraints may appear in any kind of source file (not just Go), but they must appear near the top of the file, preceded only by blank lines and other line comments. These rules mean that in Go files a build constraint must appear before the package clause.
To distinguish build constraints from package documentation, a series of build constraints must be followed by a blank line.
A working example:
1 // +build go1.6
2
3 package yourpackage
Note that go1.17 onward supports a new build tag format that has a more explicit syntax and which go fmt is aware of: See https://pkg.go.dev/cmd/go#hdr-Build_constraints for full details.
//go:build go1.17
(don't forget the newline after the build constraint)

Extending <redirect:write> in xalan

In my project, I have used the function which xaln provided. Now I need to write another function to fix the meta data of the file which is generated by . So the code just like below:
<redirect:write file="file.html">
<xsl:variable name="meta_fix" select="MetaFix:fix(string,string('file.html'))" /> //call the fix function which is an external java function.
However, what i really want is to extend the xalan redirect function and make a customize tag which will be processed just like the
<customize:write file="file.html" fixMeta="t" />
//or
<redirect:customize-write file="file.html" fixMeta="t" />
How can I extend the xalan write function and make the xalan understand my customize tag?
I believe it's possible to plug an Entity Resolver into Xalan which will be able to review and rewrite URIs, which might let you put your hint into the URI rather than a separate flag variable or attribute. Check the documentation on Apache.
Or I suppose you could try copying the logic of redirect: out of the guts of xalan and adapting apprpriately, then plugging it in as an extension element. I don't remember whether extensions would be able to access enough of xalan's guts to make that work, though, and persionally I wouldn't try it since you'd be making your stylesheets extremely nonportable.

CFEclipse doesn't recognize structName in cfimage tag

This code:
<cfimage action="info" structName="imageInfo" source="#imagePath#">
is giving this error:
The attribute 'structName' is required for the tag. (Found:
[source, structname, action])
When I run this code in CFBuilder - everything is OK, but I must use CFEclipse.
What should I do (I use CF9)?
Thank you for your answers!
Of course this problem won't prevent you from running your application on ColdFusion. It is just an IDE warning that something is wrong.
You have a few options.
Try using a lowercase N in structName. i.e. structname. ColdFusion is not case-sensitive, but Java is, and CFEclipse is a Java application.
If that does not work, then it probably means that the dictionary file that drives the code assist is not correct. You can go earch forthose XML files and update them to include that attribute.
You can use CFBuilder. I know you said you can't, but I have to question why. You know there is a free version that is just as good as CFEclipse, right?
The problem is that there's a casing glitch in that file Peter mentions. There's one reference to "structName" to define the attribute itself, and another "structname" which is in the list defining which attributes are needed for action="info". If you make them both the same, then restart Eclipse, you should be OK (that's I've needed to do to make the error indicator go away).