Option for using scale-down-to-fit with a2x and FOP - apache-fop

I'm doing a build system for a documentation project and I need help trying to limit the width of images when generating PDF output.
I'm using a2x --fop to generate the PDF output which works fine, but I need the scale-down-to-fit option (Scale down to fit an image in FOP) enabled for all images.
How can I enable this while using a2x --fop?

Remarkably, I managed to sort this out even though XSL(T) is all smoke and mirrors to me!
To enable this, I managed to get an XSL example from http://www.renderx.com/usecasestest.html and example the XML produced by a2x to craft the following snippet which I've currently added to the default fo.xsl included with asciidoc/a2x:
<xsl:template match="imagedata">
<fo:block line-height="1pt">
<fo:external-graphic content-width="scale-down-to-fit" content-height="100%" width="100%" scaling="uniform">
<xsl:attribute name="src">
url(
<xsl:value-of select="#fileref"/>
)
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</xsl:template>

Related

Ektron Forms - Generate Plaintext Email

In Ektron I have a form that generates an HTML email on submission and sends it to a mailbox (foo#bar.com). An application (MailReader) checks that mailbox, reads the messages, strips all markup, and saves the resulting messages for later use. This is a problem because all the text from the HTML email end up getting mashed together and are completely unreadable by someone using the MailReader app.
For example, this HTML:
<h1>Header1</h1>
<div>
<h2>Header2</h2>
<p>Some text in a paragraph.</p>
</div>
Becomes:
Header1Header2Some text in a paragraph.
I cannot change MailReader in any way, it will always strip any markup so my solution is to have Ektron generate an email that contains no HTML for just this form. I know the email is generated using XSLT transformations with the file /Workarea/controls/forms/DefaultFormEmailBody.xslt.
My attempt at my solution involved adding a hidden input to the form with name "__nohtml". Then the XSLT will do the following:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:choose>
<xsl:when test="/field[starts-with(#name, '__nohtml')]">
<xsl:output method="text" />
</xsl:when>
<xsl:otherwise>
<xsl:output method="html" />
</xsl:otherwise>
</xsl:choose>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/field[starts-with(#name, '__nohtml')]">
text output
</xsl:when>
<xsl:otherwise>
html output
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
But it never sends the email when I use this. I tried just rendering with this template on my own machine and I get errors. And I've also noticed that w3 documentation says the The xsl:output element is only allowed as a top-level element. That probably explains why I can't put it in the element.
I've also tried just completely omitting the element and it seems to default to HTML no matter what.
I've tried searching our local Ektron code for the point where the transformation occurs so I can tell Ektron to use the default XSLT in standard cases or use a different XSLT if __nohtml exists, but I don't know if that code is even accessible.
I would greatly appreciate it if someone can help me find a template that would allow either HTML or plaintext based on whether a field exists. If not then it would be equally awesome if someone could point me to the point of XSLT transformation in Ektron's code (if it's even accessible).
I would recommend a form strategy to generate a version of an email that you build out. There should be a public override void OnAfterSubmit(FormData formData, FormSubmittedData submittedFormData, string formXml, CmsEventArgs eventArgs) that would allow you to create pull out the submitted form data (either in the raw object or I believe it returns the xml as well. From there you could just parse it and save your html file.

In Filemaker, is it possible to import into Container fields from XML?

The XML FMPXMLRESULT grammar documentation states:
XML export does not support exporting container field data.
which seems to imply that it's possible to import (it does also specify that you can denote a field as type "CONTAINER" in the XML). However, I have found zero documentation as to how this might be done.
Is it possible? I get that there are ways of getting e.g. an image file into Filemaker after the fact, but can I just specify it in the XML beforehand, negating the need to have additional scripts or post-processing the import (not to mention something that works in Filemaker 11 or below)?
You can import file references, but not binary data. (And you'll have to specify the field as TEXT type in the XML file.) For example:
<?xml version="1.0" encoding="UTF-8"?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="01-25-2011" NAME="FileMaker"
VERSION="ProAdvanced 11.0v3" />
<DATABASE DATEFORMAT="M/d/yyyy" TIMEFORMAT="h:mm:ss a"
LAYOUT="" NAME="" RECORDS="" />
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" TYPE="TEXT" NAME="Path" />
</METADATA>
<RESULTSET FOUND="">
<ROW>
<COL>
<DATA>image:test.jpg</DATA>
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>
The path must be in FileMaker format; here I used a relative path to test.jpg in the same directory as the file (will only work for local files), but it can also be an absolute path, e.g.:
imagewin:/C:/Some/Path/test.jpg
Your best option is probably to import Base64-encoded data, then use the Base64Decode function to decode it.
importing images, preferably from http
I am not sure what exactly that means. If your XML contains a link to an image, then the only thing you can do with it is import the link as text. If you are using version 12 or higher, you can follow this with the Insert From URL script step (for each imported record).

Can I use css3 in my Birt Report?

I want to use CSS3 in my Birt Report. But its showing the problem of CSS2.
A BIRT exception occurred.
Plug-in Provider:Eclipse BIRT Project
Plug-in Name:BIRT Model
Plug-in ID:org.eclipse.birt.report.model
Version:4.3.1.v201308301349
Error Code:Error.StyleSheetException.SYNTAX_ERROR
Error Message:There are some syntax errors inconsistent with CSS2.
So can anyone help me like how can I use my CSS3 file for my report. Is there any plugin or some steps then please let me know.
You can use css3 in html format only, by including the css file at viewtime. But it would be ignored by pdf & other formats.
For example, we are going to include this jquery-mobile theme at viewtime:
//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.2/jquery.mobile.min.css
To test this example, add a BIRT text element in the report, set type to HTML and include fragment below:
<button data-icon="star" data-theme="a" data-form="ui-btn-up-a" class=" ui-btn ui-btn-a ui-icon-star ui-btn-icon-left ui-shadow ui-corner-all">Button</button>
Run the report, you will see a great jqueryMobile-like css3 button!
You can also load the external files in the clientScripts of the report using head.js. For example, in a report's clientScripts > clientInitialize event, add:
head.js("http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js",
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css");
In the XML source, this appears as the last line in the following code.
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.4.0.v20150206-1039 Build <4.2.3.v20150206-1039></property>
<property name="units">in</property>
<method name="clientInitialize"><![CDATA[head.js("http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js", "http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css");
]]></method>

Umbraco XSLT RenderTemplate Woes

Needing a little guidance with XSLT and Umbraco. Fairly new to XSLT but I think I understand the concepts. Right on one page I have two columns, each with their own separate pickable content. This is done via the standard content picker property (one for each column). The issue is that I need to be able to have two different templates on the page. So in essence the page navigated two which has the columns has to render two of it's child items in its own page.
I have this working with one column using a generic XSLT which I found that basically just renders what ever child item it finds, but I want it to render what ever one the user picked.
I know the Content Picker returns the XML Node ID of the page and that can be used with the Render Template function to display it (I have an example of that), but when it comes to adding in my own properties and then passing them to the RenderTemplate function I get lost. New to this XSLT :).
So far I have...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="nodeID" select="data[#alias='leftColumn']"/>
<xsl:template match="/">
<xsl:value-of select="umbraco.library:RenderTemplate($nodeID)" disable-output-escaping="yes"/>
</xsl:template>
</xsl:stylesheet>
Any one know why this doesn't work and how to do what I'm after? The above gives a value was either too large or too small error.
You actually have two problems here ...
Calling RenderTemplate()
RenderTemplate actually requires two arguments when using an alternative template, the first being the content node ID, and the second being the chosen template you want applied.
<xsl:value-of
select="umbraco.library:RenderTemplate($nodeID, $templateID)"
disable-output-escaping="yes" />
See the following link for more information : http://our.umbraco.org/wiki/reference/umbracolibrary/rendertemplate
Too large or too small error
This one is simple to fix by putting an if-empty statement around the the code in question.
<xsl:if test="$nodeID != ''">
<xsl:value-of
select="umbraco.library:RenderTemplate($nodeID, $templateID)"
disable-output-escaping="yes" />
</xsl:if>
The XSLT parser likes to assume certain values are null, when in reality they aren't. Another way to get by this is to check the Skip Errors checkbox when saving, but this makes debugging actual erroneous code a bit of a pain.
Hope it helps.

Using XSLT 2.0 tags in Crystal Reports 2008

As part of a task at work I'm looking at exporting a simple list of details from a Crystal Report into separate xml files, one for each row.
The list is basic employee info i.e. First name, Surname etc.
Using Crystal Reports 2008 and quickly reading up on XSLT, I've managed to write a transformation that places each employee in it's own element with child-elements detailing its information.
However, i'm trying to use the xsl:result-document command, but Crystal Reports doesn't seem to like it. My XSLT file works fine in SAXON and splits the xml into separate files, but Crystal ignores everything inside the tag completely and just displays the header info.
Has anybody else had a similar problem?
I'm aware that the result-document tag was made available in XSLT 2.0, so would I be right in guessing the processor in Crystal Reports 2008 only works with XSLT 1.0? If so is there a way I can force it to work with XSLT 2.0?
Thanks for your time,
Ben
Below is my XSLT file:
<?xml version='1.0' ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="urn:crystal-reports:schemas:report-detail">
<xsl:template match="/b:CrystalReport">
<Report>
<xsl:for-each select="b:Details">
<xsl:variable name="empnumber" select="b:Section/b:Field[#Name='EmployeeNumber1']/b:Value"/>
<xsl:result-document href="{$empnumber}.xml">
<Employee>
<xsl:attribute name="ID">
<xsl:value-of select="b:Section/b:Field[#Name='EmployeeNumber1']/b:Value"/>
</xsl:attribute>
<FirstName>
<xsl:value-of select="b:Section/b:Field[#Name='FirstName1']/b:Value"/>
</FirstName>
<Surname>
<xsl:value-of select="b:Section/b:Field[#Name='Surname1']/b:Value"/>
</Surname>
<Test>
<xsl:value-of select="$empnumber" />
</Test>
</Employee>
</xsl:result-document>
</xsl:for-each>
</Report>
</xsl:template>
</xsl:stylesheet>
so would I be right in guessing the
processor in Crystal Reports 2008 only
works with XSLT 1.0? If so is there a
way I can force it to work with XSLT
2.0?
The short answer: no. However, some products allow to connect to a third party processor. I'm not aware of this option for Crystal Reports though. Also, result-document is a sufficiently complex instruction which is not easy to allow through extension functions.
Thinking about this more: aren't you simply using .NET to do the transformation? Out of the box, .NET only supports XSLT 1.0 (despite past promises otherwise). Because what you can do is to export the XML from Crystal Reports and transform that with an XSLT 2.0 processor. Saxon has been ported to .NET using IKVM.