I'm working on a PFD drawing OMR function that use the page number of apache-fop for computation, but when I assign the page number retrieved from the tag to the < XSL :variable> tag , I get not a number, but a DOM node, because I want to compute the page number by embedding it in Java,could you give me some hints?
<xsl:variable name="number">
<fo:page-number/>
<xsl:variable>
<xsl:value-of select="java:XslFunctions.calculate($number)"
It's an old question but i give an answer for others that can be found it useful. There is a property built-in that can be used. Below you can find an example of working code where the page number is added in the pages footer:
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4"
page-height="21cm" page-width="29.7cm" margin-top="1cm"
margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
<fo:region-body />
<fo:region-after region-name="footer" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4" initial-page-number="1" id="end">
<fo:static-content flow-name="footer" font-size="7pt">
<fo:block>
Page: <fo:page-number/>/<fo:page-number-citation-last ref-id="end"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
.......
.......
</fo:flow>
</fo:page-sequence>
Important the identifier specified in fo:page-number-citation-last --> 'ref-id="end"' must be equals to id="end" specified in the fo:page-sequence
Related
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>
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.
Umbraco newbie here. I've researched a tonne but can't seem to find what I' looking for.
I have a site with a slider on the homepage, the slider is sitting in a macro which is using a for-each (of a nodes children) with a final goal to display the 'heroImage' image from that doctype. I cant post images as a newbie to this site, but heres my content structure:
HOME
PORTFOLIO
- First Item
- Another Item
ABOUT
CONTACT US
Home, Portfolio, ABOUT and CONTACT US are "Landing Pages" document types, and the children under Portfolio (First Item and Another Item) are "Portfolio Entries" document types. Below is the code on "Landing Page" calling the Slideshow macro.
Portfolio Entry has fields:
heroImage
images
body
Slideshow macro obviously being the highlight there. Easy enough. Heres my macro code where you'll see I'm trying to display the heroImage of the node in question for each 'for-each'.
<xsl:template match="/">
<!-- slider -->
<div id="slideshow">
<div id="slider" class="nivoSlider">
<xsl:for-each select="umbraco.library:GetXmlNodeById(1081)/*[#isDoc and position() < 4]">
<xsl:variable name="mediaId" select="umbraco.library:GetMedia(#id, 'false')/data [#alias = 'umbracoFile']" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="count($mediaNode/data) > 0 and string($mediaNode/data[#alias='umbracoFile']) != ''">
<img src="{$mediaNode/data[#alias='umbracoFile']}" alt="[image]" />
</xsl:if>
</xsl:if>
</xsl:for-each>
</div>
</div>
<!-- data-transition="slideInLeft" -->
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
</xsl:template>
I feel like im so close, and ran out of search queries as most of the solutions I found were dependant on the imageId being passed onto the macro from the other side of the macro which wouldn't work.
Hope Ive explained this enough and thanks in advance for your help!
First of all, it looks like you're hardcoding the parent node id. In the code you just provided, it seems to only be getting the children of the node with id 1081. From reading what you just posted, it would seem that on all landing pages, you want to display their individual portfolio entries.
Either way, I would stay away from hardcoding IDs. If the node id changes in any way(user deletes the node, it gets exported as a package to the live environment, etc), your code will stop working. I'd just use $currentPage instead.
Judging by your filter, I imagine you only want the first 3 items to show in the slider. The code seems correct, but you seem to be using the old schema and its associated xpath. If you're using a newer version of Umbraco, the way you reference node data in xslt would have changed. I would guess that you've found many code examples and tried merging them together, without realising they wouldn't call the same schema.
This wiki link will provide more information, and hopefully fix your problem if you're using the wrong xpath.
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.
I am asking this question to test the validity of my HTML. I can very well try this out (and I have, and it's possible), but I'm simply curious whether or not this is allowed in HTML. If not, how can one simulate a div or span element inside a form? Using blockquote?
form is a block-level element in HTML. Typically, block-level elements allow both block-level and inline children. Both div and span are valid children of form.
There are a ton of resources online to learn more about this topic, for example:
http://www.w3.org/TR/html4/struct/global.html#h-7.5.3
It may also benefit you to read about the box model, as this is one of the most fundamental concepts of web design/development.
http://www.w3.org/TR/CSS2/box.html
Yes, you can. And it is also "officially allowed" by the XHTML standard, if you look into the XHTML XSD, you will find
<xs:complexType name="form.content">
<xs:annotation>
<xs:documentation>
form uses "Block" excluding form
</xs:documentation>
</xs:annotation>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="block"/>
<xs:group ref="misc"/>
</xs:choice>
</xs:complexType>
"block" encompasses div and "misc" contains span. The "documentation" part points out one particular thing you are not allowed to do: nest a form within another one.
Yes it's valid and you can use any number of divs, spans or blockquotes inside a form. You can always use W3C Markup Validation Service to check your html.
Eg:
<body>
<form id="Form1">
<div id="wrap">
<div id="content-wrap" class="content-wrap-admin">
</div>
</div>
</form>
</body>
I must correct emboss' answer.
In the XHTML 1.0 Strict DTD that he quotes, the group misc does not refer to inline elements. Instead, it refers to the following 4 elements: noscript, ins, del and script.
<!ENTITY % misc.inline "ins | del | script">
<!ENTITY % misc "noscript | %misc.inline;">
So to answer the question, XHTML 1.0 Strict does not allow span elements inside form elements. You'll need to wrap them inside block elements such as p, dip or fieldset.
This is not the case with XHTML 1.0 Transitional, though. Indeed, the DTD indicates that inline elements are allowed inside form elements:
<!ENTITY % form.content "(#PCDATA | %block; | %inline; | %misc;)*">
For reference: XHTML 1.0 - DTDs
Yes.
Did you even try this yourself?