Calabash 1.0.23 throws on xsl-formatter step: ERROR: Failed to instantiate FO provider - apache-fop

I'm trying to use XML Calabash 1.0.23 to run XSLT transformation and FO formatting in a single pipeline. Although the XSLT step works fine, I cannot get the xsl-formatter step to work with FOP.
Every time I run the pipeline, Calabash throws:
ERROR: pipeline.xpl:13:68:Failed to instantiate FO provider
ERROR: Underlying exception: org/apache/fop/apps/FopFactory
My call to Calabash from the command line is:
java com.xmlcalabash.drivers.Main -c cfg.xml myPipeline.xpl
And the cfg.xml configuration file being referred to in the above line is:
<cc:xproc-config xmlns:cc="http://xmlcalabash.com/ns/configuration">
<cc:fo-processor class-name="com.xmlcalabash.util.FoFOP"/>
</cc:xproc-config>
For some reason, Calabash seems to ignore the config file setting, because regardless of the value of the class-name attribute on <cc:fo-processor>, it always throws the same error message. For example, if I use com.xmlcalabash.util.FoAH, the same happens; and if put a nonsensical value, the same occurs. It's always an exception on org/apache/fop/apps/FopFactory.
Just for the sake of completeness, this is my XPL:
<declare-step name="main" version="1.0" xmlns="http://www.w3.org/ns/xproc">
<input port="parameters" kind="parameter" />
<xslt name="transformation">
<input port="source">
<document href="myMarkup.xml" />
</input>
<input port="stylesheet">
<document href="myStylesheet.xsl" />
</input>
</xslt>
<xsl-formatter href="newDoc.pdf" >
<input port="source">
<pipe step="transformation" port="result" />
</input>
</xsl-formatter>
</declare-step>
Of course, if I manually pass the generated FO from the XSLT step to FOP 1.1, it converts it to PDF with no problems. The issue only arises when trying to do the conversion within the pipeline.
I could really use some help to solve this. I'm clueless at this point.

This may seem like a very pedantic reply, but do you have fop.jar (and fop-hyph.jar, which I think FOP requires) on your classpath? They're not bundled in the XML Calabash distribution, you have to get them from Apache.

Related

ERROR in There is a placeholder name mismatch with the translation provided

We use #angular/localize (Version 9.1.12) and have a problem with the placeholders in localized text.
E. g. we have:
$localize`:##form.hint:Some text ${name} in service.`;
or
$localize`:##form.hint:Some text ${name}:name: in service.`;
Because the localize text strings in typescript files aren't extracted we put these into a component template.
E. g.:
<p i18n="##form.hint">Some text {{ name }} in service.</p>
After execution of xi18n we get the messages.xlf (and messages.de.xlf) files which contain the following:
<trans-unit id="form.hint" datatype="html">
<source>Some text <x id="INTERPOLATION" equiv-text="{{ name }}"/> in service.</source>
<target state="new">Some text <x id="INTERPOLATION" equiv-text="{{ name }}"/> in service.</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/translation/translation.component.html</context>
<context context-type="linenumber">207</context>
</context-group>
</trans-unit>
When we start the application with ng serve we get the following error:
ERROR in There is a placeholder name mismatch with the translation provided for the message "form.hint" ("Some text {$PH} in service.").
The translation contains a placeholder with name INTERPOLATION, which does not exist in the message.
The application does not work. After a restart the error does not occur and the application works. Nothing was changed before the restart.
We can work with a local restart but after each change of the messages.xlf files the error occurs again and we need two ci-builds on our build server to get a working installation on our test machine.
Any ideas what can be the cause of the placeholder mismatch?
For the current angular version (10.1.3) you need to opt in to extraction of translation tokens via ivy:
ng xi18n --ivy
The result will include texts from $localize.

XSLT streaming not streaming

I'm using Saxon-EE for the purpose of streaming XSLT transformation of large XML. The transformation works fine but it seems it's not really streaming since the java.exe process is inflating: for a 100 MB XML, process memory increases ~1GB. This is the XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:bb="urn:xx-zz-1.1"
xmlns:aa="urn:xx-yy-1.1">
<xsl:mode streamable="yes"/>
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:for-each select="aa:LevelOne/aa:LevelTwo">
<xsl:iterate select="bb:LevelThree! copy-of(.)">
<xsl:value-of select="concat(bb:fieldOne,',',bb:fieldTwo,'
')"/>
</xsl:iterate>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This is the XML:
<?xml version="1.0" encoding="utf-8"?>
<aa:LevelOne xmlns="urn:xx-zz-1.1" xmlns:aa="urn:xx-yy-1.1">
<aa:LevelTwo xmlns="urn:xx-zz-1.1" xmlns:aa="urn:xx-yy-1.1">
<LevelThree xmlns="urn:xx-zz-1.1">
<fieldOne>f1</fieldOne>
<fieldTwo>f2</fieldTwo>
</LevelThree>
<!-- Level three is repeated many times -->
</aa:LevelTwo>
</aa:LevelOne>
I would like to know if there (& what) is a problem with the XSLT above.
The code I use:
net.sf.saxon.s9api.Processor processor = new net.sf.saxon.s9api.Processor(true);
processor.setConfigurationProperty(Feature.STREAMABILITY, "standard");
XsltCompiler compiler = processor.newXsltCompiler();
XsltExecutable stylesheet = compiler.compile(new StreamSource(stylesheetFile));
Serializer out = processor.newSerializer(outputCsvFile);
Xslt30Transformer transformer = stylesheet.load30();
transformer.applyTemplates(new StreamSource(xmlFile), out);
EDIT: Fixed the XSLT so it compiles & added XML example.
Remark: using command java -cp "<path>\test;<path>\saxon9ee.jar" com.example.test.Test -t does not ouput additional info (only the printlns in the code). java -cp "<path>\test;<path>\saxon9ee.jar" -t com.example.test.Test outputs: Unrecognized option: -Xt Error: Could not create the Java Virtual Machine. If I change the XSLT to non-streamable rule e.g. remove the iterate line, program outputs Template rule is not streamable, also without -t option. In this case if I remove the streamability requirement from code/xslt, the error goes away.
Thanks.
Probably the most likely reason Saxon would fall back to non-streaming mode is that it hasn't located a Saxon-EE license. The easiest way to test that is (unintuitively!) by calling processor.isSchemaAware() - that will only be true if you're running Saxon-EE code with a recognized license, which is exactly the same condition to enable streaming.
If it hasn't found a license, the Saxon documentation includes a section on troubleshooting license problems at http://www.saxonica.com/documentation/index.html#!about/license
Also, try it from the command line with option -t; that will give you more information (a) about streaming, and (b) about loading of license files.
I think, if the data is as simple and as regular as shown in the question, then you can avoid the use of copy-of() and simply use
<xsl:iterate select="bb:LevelThree">
<xsl:value-of select="bb:*" separator=","/>
<xsl:text>
</xsl:text>
</xsl:iterate>
That in a quick test shows a reduced memory consumption compared to your posted approach.
As for your posted approach not using streaming with Saxon EE 9.9, I have tested the posted XSLT and the input sample with Saxon 9.9 EE from the command line with the -t option and it shows the input is streamed.
I also think the Java code shown is fine to process the file with streaming with Saxon EE.
For a detailed analysis of the memory consumption and any problems you encounter with that it might be better to raise an issue with all details on the Saxonica support site. I am not sure how the memory info Saxon outputs relates exactly to the one you say you see for java.exe.

How to write AssemblyVersion to file using MSBuild?

FinalEdit: Despite relative directories not working in the first post, it worked if I simply removed the $(MsBuildThisFileDirectory) from the Exec line.
Edit2: I added the new targets to the DefaultTargets. Which now runs them by default. However, timing was now off with the postbuild command. I added <Exec Command="call $(MsBuildThisFileDirectory)documentation\tools\GenerateDocumentation.bat" IgnoreExitCode="false" /> to the target, but it gives an error that C:\Users\my is not a valid batch file because of the space which is actually C:\Users\my program\documentation\tools\GenerateDocumentation.bat. Putting quotes around the path gives me error MSB4025 that Name cannot begin with $.
Edit: I have tried stijn's code and it works when I explicitly run it from the command line using /t:RetrieveIdentities, but for some reason it doesn't seem to run otherwise.
I have been using Doxygen to generate documentation for my source code, however, I would like to be able to do it automatically. I wrote a simple .bat script to run Doxygen with my desired config file and compile the output into a .chm help file, but I have been unable to change the revision number automatically in Doxygen.
I was attempting to simply update the config file by adding a new line to the config file with the new revision number using MSBuild, but I have been unable to get anything to print or even create a new file when none is present.
The code I have so far I have gotten from other similar questions, but I cannot seem to get it to work.
<ItemGroup>
<MyTextFile Include="\documentation\DoxygenConfigFile.doxyconfig"/>
<MyItems Include="PROJECT_NUMBER = %(MyAssemblyIdentitiesAssemblyInfo.Version)"/>
</ItemGroup>
<Target Name="RetrieveIdentities">
<GetAssemblyIdentity AssemblyFiles="bin\foo.exe">
<Output TaskParameter="Assemblies" ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
<WriteLinesToFile File="#(MyTextFile)" Lines="#(MyItems)" Overwrite="false" Encoding="UTF8" />
</Target>
Encoding is wrong, it should be UTF-8
When working with items/properties, the % and # and $ must come right before the (, no spacing in between: %(MyAssemblyIdentitiesAssemblyInfo.Version)
MyAssemblyIdentitiesAssemblyInfo does not exist, you probably meant MyAssemblyIdentities
Look up how msbuild evaluates properties and items. Basically what it will do in your script is evaluate MyItems, but at that time MyAssemblyIdentities does not yet exist so is empty, and only afterwards the GetAssemblyIdentity gets executed. Fix this by enforcing correct evaluation order: put your items inside the target and make it depend on another target that creates MyAssemblyIdentities before evaluating your items.
To summarize:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="GetAssemblyIdentities">
<GetAssemblyIdentity AssemblyFiles="bin\foo.exe">
<Output TaskParameter="Assemblies" ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
</Target>
<Target Name="RetrieveIdentities" DependsOnTargets="GetAssemblyIdentities">
<ItemGroup>
<MyTextFile Include="\documentation\DoxygenConfigFile.doxyconfig"/>
<MyItems Include="PROJECT_NUMBER = %(MyAssemblyIdentities.Version)"/>
</ItemGroup>
<WriteLinesToFile File="#(MyTextFile)" Lines="#(MyItems)"
Overwrite="false" Encoding="UTF-8" />
</Target>
</Project>
Note this will only work if you invoke msbuild in the directory where the script is, else the paths (documentation/foo) will be wrong. That could be fixed by using eg $(MsBuildThisFileDirectory)\bin\foo.exe)

How do I config xml namespace for a smooks input file using WSO2?

I couldn't find any advices on how to setup Smooks (on WSO2 Developer Studio 3.1) in order to it properly read a xml input which has a namespace declaration.
Without the namespace the transformation works just fine!
By informing the xmlns in the input, I get this exception:
Error on line 5, column 19 in free-marker-template
Expecting a string, date or number here, Expression .vars["order"]["order-items/order-item/#id"] is instead a freemarker.ext.dom.NodeListModel
The problematic instruction:
----------
==> ${.vars["order"]["order-items/order-item/#id"]} [on line 5, column 17 in free-marker-template]
These are both my input and output:
<order id='444' xmlns="http://example.com">
<header>
<customer number="555">Amila</customer>
</header>
<order-items>
<order-item id='1'>
<product>1</product>
<quantity>2</quantity>
<price>400</price>
</order-item>
</order-items>
</order>
<salesorder>
<details>
<orderid></orderid>
<customer>
<id></id>
<name></name>
</customer>
</details>
<itemList>
<item>
<id></id>
<productId></productId>
<quantity></quantity>
<price></price>
</item>
</itemList>
</salesorder>
I've also tried Smooks coreĀ“s namespace declarations as per Smooks site:
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
>
<core:namespaces>
<core:namespace prefix="ex" uri="http://example.com/"/>
</core:namespaces>
But it seems not to be supported in the IDE since the configuration editor raises this exception:
-Value 'org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl#53abd5a9 (mixed: null, anyAttribute: null)' is not legal. (platform:/resource/Corp/smooks-config.xml,6,20)
Well, any idea?
Instead of Smooks, can't you use a XSLT? It will avoid the namespace issue you have.

Unity Container not Resolving my Type

I am working in a project that is using unity. The first element was already in the web.config and is resolving correctly. The second one (IEventRepository) was added by me. It will not resolve the type and throws an error ("Resolution of the dependency failed..")
I have 2 questions on this:
1) What is the issue?
2) Why does the first one have commas in it?
Thanks
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="Demo.IPerson, Demo.Shared.Facilities" mapTo="Person, Demo.Shared.Facilities" />
<register type="Web.Repositories.IEventRepository" mapTo="Web.Repositories.MockEventRepository" />
</container>
</unity>
The purpose of the commas is to separate the Type and Assembly. For example, in the first line Demo.IPerson is the Type and this type is in the Demo.Shared.Facilities assembly. In the second line you haven't specified both the Type and Assembly which could be the reason for the error.
The way you have configured the registration in line 2 could work if you have defined a type alias. Have a look at The Unity Configuration Schema