I have a report in XML that is formatted using xslt. I need to display a checkbox next to some text. Currently this is the xslt
<TableHeaderRow>
<TableHeaderCell colspan="4">
<TableCommentsText>
☐ <xsl:value-of select="/ReportForm/Comments1/Paragraph/#Text" />
</TableCommentsText>
</TableHeaderCell>
</TableHeaderRow>
This is not working. My output comes out blank before the text. If I use &# 174; (®) it's working fine.
What can I do to get the CheckBox?
Thanks.
Related
We have 60-odd images that we want to include, and want to insert them into a doc using a variable name in the src attribute. Here is the code that currently isn't working:
Without XSL:-
<var name="Request.Data.Communication.AddressStructured.Sender.OrgId" type="string" />
<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:svg="http://www.w3.org/2000/svg" xmlns:th="http://www.thunderhead.com/XSL/Extensions" font-family="Frutiger 45 Light">
<fo:external-graphic content-height="30mm" content-width="100mm" src="cms:///Resources/Images/Request.Data.Communication.AddressStructured.Sender.OrgId.jpg" />
</fo:block>
With XSL:-
<xsl:block xmlns:xsl="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:svg="http://www.w3.org/2000/svg"
<xsl:var name="Request.Data.Communication.AddressStructured.Sender.OrgId" select="Request.Data.Communication.AddressStructured.Sender.OrgId"/>
<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Transform" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:svg="http://www.w3.org/2000/svg" <fo:external-graphic content-height="30mm" content-width="100mm" src="cms:///Resources/Images/${Request.Data.Communication.AddressStructured.Sender.OrgId}.jpg" />
</fo:block>
</xsl:block>
You might want {$Request.Data.Communication.AddressStructured.Sender.OrgId} rather than ${Request.Data.Communication.AddressStructured.Sender.OrgId}, otherwise read on...
Getting from your source XML to PDF output is a two-step process (unless, that is, you author documents directly in the XSL-FO vocabulary). The steps are:
An XSLT transformation transforms your XML into XML in the XSL-FO vocabulary that an XSL Formatter understands
An XSL Formatter formats the XSL-FO to make pages and outputs those pages as PDF, SVG, etc.
This graphic from the XSL 1.1 Recommendation (https://www.w3.org/TR/xsl11/#d0e147) tries to illustrate the process:
The XSLT stage has variables, but the XSL-FO stage does not. (You can write expressions for the value of (most) XSL-FO properties, but the expression language (see https://www.w3.org/TR/xsl11/#d0e5032) doesn't stretch to having variables.)
So, in your XSLT stylesheet, you would have something like:
{$Request.Data.Communication.AddressStructured.Sender.OrgId}.jpg
where:
$Request.Data.Communication.AddressStructured.Sender.OrgId is a variable (or parameter) reference. We don't have enough information to know how you'd define the variable.
{...} is an Attribute Value Template (AVT) that is used when you want to evaluate an expression to generate some or all of an attribute value.
The output from the XSLT stage would include the literal string resulting from evaluating the expression, and the XSL Formatter will use the actual URL to locate the image correctly.
I have a custom list. That custom list has a plain text milti-line field. In it the user will enter HTML, like <br>hi</br>;
I want to render that HTML in my DVWP using XSLT.
<xsl:value-of select="#Field_Name" disable-output-escaping="no" /> outputs <b>hi</b>
<xsl:value-of select="#Field_Name" disable-output-escaping="Yes" /> outputs <b>hi</b>
Anyway I can make it render the actual HTML? So I want it to output hi.
Change your custom field from Plain text to Rich text type because plain text assume <b>hi</b> as part of data. If you change your field type can see html formated text in your browser with same xslt code like hi.
I have a DITA bookmap where I am storing image paths:
<bookmap>
<bookmeta>
<data id="productLogo">
<image href="images/_notrans/frontcover/productLogo.svg" />
</data>
<data id="productPhoto" >
<image href="images/_notrans/frontcover/productPhoto.jpg" />
</data>
</bookmeta>
</bookmap>
Then I attempt to grab the href values by data[#id]:
<xsl:variable name="productLogo"><xsl:value-of select="//data[#id='productLogo']/image/#href" /></xsl:variable>
<xsl:variable name="productPhoto"><xsl:value-of select="//data[#id='productPhoto']/image/#href" /></xsl:variable>
(These XPath expressions match the href when I test against my bookmap in Oxygen.)
During transformation I output:
<xsl:message>productPhoto: <xsl:value-of select="$productPhoto"/></xsl:message>
The value-of is always empty.
However, everything works as expected if I replace the id attribute with numbers:
<xsl:variable name="productLogo"><xsl:value-of select="//data[1]/image/#href" /></xsl:variable>
<xsl:variable name="productPhoto"><xsl:value-of select="//data[2]/image/#href" /></xsl:variable>
What am I doing wrong that's preventing using #id="whatever"?
The XSLT is not applied directly over the Bookmap contents, it is applied over an XML document which contains the bookmap with all topic references expanded in it and with some preprocessing applied to it.
If you set the "clean.temp" parameter to "no" you will find in the temporary files folder a file called something like "mapName_MERGED.xml", that is the XML document over which the XSLT is applied and as you will see in it, all IDs have been changed to be unique in the context of the entire XML document.
When usually working with data elements you should set the #name attribute to them like:
<data name="productLogo">
and match that name in the XSLT code.
There are examples of using "data" in the DITA 1.2 specs as well:
http://docs.oasis-open.org/dita/v1.2/os/spec/langref/data.html#data
Another option, depending on your needs, is to develop a naming convention for the product photos and use the element to build the URI. As the product logo shouldn't change for a product family, it wouldn't hurt to hard-code that in the XSLT code.
I am working with XML files that are generated by a digital video camera. The camera allows the user to save all of the camera's settngs to an SD card so that the settings can be recalled or loaded into another camera. The XSL stylesheet I am writing will allow users to view the camera's settings, as saved to the SD card in a web browser.
While most of the values in the XML file -- as formatted by my stylesheet -- make sense to humans, some do not. What I would like to do is have the stylesheet display text that is based on the value in the XML file but more easily understood by humans.
My sample XML file may be viewed here: http://josephthomas.info/Alexa/Setup_120511_140322.xml
A few lines down the page you will see:
Color GAMMA-SxS Rec_Log
While "Rec_Log" is a value that the cameras understand, it is not a value that the camera's users will understand. What I would like for the stylesheet to do is to display "LogC" instead.
In the XML file this value is defined thusly:
<DteLut lowerLimit="0" upperLimit="2">Rec_Log</DteLut>
The XSL formatting the sample page for this value is:
<tr>
<td class="title_column">Color GAMMA-SxS</td><td><xsl:value-of select="Settings/Groups/Recording/DteLut"/>
</td>
</tr>
So what I hope to do is have "LogC" displayed on the page rather than Rec_Log.
It seems to me that the "when" conditional statement is the correct approach, but I am not familiar enough with the syntax to cause this to happen. There are other values in the XML file that want replacing but the above is a good example of my mission.
What you could do is make use of make use of template matching, to match the exceptions to what you want to change. Firstly, add the following template to your XSL
<xsl:template match="DteLut[. = 'Rec_Log']">
<xsl:text>LogC</xsl:text>
</xsl:template>
Then, instead of the following line
<xsl:value-of select="Settings/Groups/Recording/DteLut"/>
Do the following line
<xsl:apply-templates select="Settings/Groups/Recording/DteLut"/>
When the value of*DteLut* is "Rec_Log", then the custom template will be matched to output "LogC" instead. When there is not a match, the default behaviour will kick in which will be to just output the text value as-is.
I would use a data-driven approach. Have a mapping file that gives all the translations:
<translations>
<translate from="Rec_log" to="LogC"/>
<translate .../>
</translations>
then define a key:
<xsl:key name="trans" match="translate" use="#from"/>
and then change
<xsl:value-of select="Settings/Groups/Recording/DteLut"/>
to
<xsl:value-of select="key('trans', Settings/Groups/Recording/DteLut,
doc('translations.xml'))/#to"/>
if using XSLT 2.0, or
<xsl:variable name="val" select="Settings/Groups/Recording/DteLut"/>
<xsl:for-each select="document('translations.xml')">
<xsl:value-of select="key('trans', $val)/#to"/>
</xsl:for-each>
if you're stuck with 1.0.
I'm trying to get hold of the querystring directly from the template in Umbraco, but can't seem to figure it out..
For example:
/mypage.aspx?p=bek
I can do it with <%=HttpContext.Current.Request["p"]%>, but I want it in a field...
Something like this:
Any ideas?
Ok, so I fixed it.
Found this:
http://forum.umbraco.org/yaf_postst6663_Get-querystring-in-template.aspx
If anyone else is interested, you do the following..
Create a xslt file with the name "QueryStringExtractor" and paste the below code where it belongs.
<xsl:param name="currentPage"/>
<xsl:variable name="yourvalue" select="//macro/myparam" />
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:value-of select="$yourvalue" />
</xsl:template>
Save and update the Umbraco page and you'll see a macro under "Macros" with the same namne.
In the macro you add the parameter "myparam" (I put it as text). Save!
Then in your template just past the following code and you're good to go!
<ul>
<umbraco:Macro Alias="QueryStringExtractor" myparam="[#p]" runat="server"></umbraco:Macro>
</ul>
So now when you enter the querystring "?p=something" you'll get "something" written on the page.
Notice that you can pass any "p" to the macro.
Hope this helps someone else!