Thank you Hussein!

With your help, I have the first item working (styling certain items as needed 
in the PDF output). I’ll try rendering the boolean values as icons later, as 
that looks a bit more complicated!

Thank you so much for the quick and detailed response. Je vous remercie!

Dan



> On Jan 20, 2025, at 8:37 AM, Hussein Shafie <[email protected]> wrote:
> 
> On 1/20/25 04:57, [email protected] wrote:
>> I’m currently evaluating the personal edition of XML Editor and XSLUtility. 
>> Overall, I really enjoy using these products and am considering purchasing 
>> the xde-usr license and XSLUtility. I really like these products and 
>> appreciate that I can run them on MacOs (unlike something like Madcap Flare 
>> or FrameMaker).
>> I have a question regarding the DITA to PDF transformation using the 
>> ditatoPDF conversion specification (Apache FOP):
>> I have a use case where I currently use the outputclass attribute, giving it 
>> a value like emphasis01, emphasis02, etc. I can then use this class with a 
>> CSS selector to style specific elements in the HTML output. I can do this 
>> just by updating the CSS stylesheet, even without using XSLUtility. Ideally, 
>> I could also use the outputclass when using the ditatoPDF transformation in 
>> XSLUtility. But I don’t see an attribute set associated with the outputclass 
>> attribute. (My current workaround is to make use of an unused element type 
>> in my XML doc—uicontrol—and then I’m doing the custom styling in the 
>> XSLUtility based on that.)
> 
> There are indeed no attribute-sets which are associated with the outputclass 
> attribute. Note that we don't see how attribute-sets could be used for that.
> 
> 
>> So is there any way to add an “outputclass = <value>” to the XSL 
>> customization? That would help tremendously and I could simply use the 
>> outputclass attribute in the XML Editor to set up a few styling things I 
>> need in both HTML and PDF outputs.
>> Similarly, it would be nice to have a way to convert a “boolean=yes" or 
>> “boolean=no" so that I could transform these guys to a “green checkmark” or 
>> “red checkbox” or some UTF character while doing the conversion.
>> Is it possible to do either of these things with the current version of 
>> XSLUtility? I might just be missing something. Or would it be possible to 
>> add something like this to the conversion options?
> 
> Yes. It's certainly possible to achieve all what you want but you'll have to 
> write custom XSLT templates for that.
> 
> Here's how to proceed:
> 
> 1) Start XSLUtility and select a DITA document to be converted to PDF. Choose 
> the ditaToPDF conversion. See attached "1app.png".
> 
> 2) Click "Edit" and select the "Transform" tab. See attached 
> "2edit_transform.png".
> 
> 3) Click "Customize" and specify the name of the file which is to contain 
> your custom XSLT templates. See attached "3customize_fo_xsl.png".
> 
> Created ".xsl" file is almost empty and looks like this:
> ---
> <?xml version="1.0" encoding="UTF-8"?>
> <?stylesheet-label ?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                version="2.0">
> 
>   <xsl:import href="xslutil-config:dita/xsl/fo/fo.xsl"/>
> 
>   <!-- REDEFINE PARAMETERS AND ATTRIBUTE-SETS HERE -->
> 
> </xsl:stylesheet>
> ---
> 
> 4) Once your customization file, e.g. "custom_fo.xsl",  has been created, 
> click the "file chooser" icon to select it. See attached 
> "4use_custom_fo_xsl.png".
> 
> 5) Now add XSLT templates to your customization file using a text or XML 
> editor.
> 
> First thing to do is declare the "fo" namespace prefix:
> ---
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                xmlns:fo="http://www.w3.org/1999/XSL/Format";
>                version="2.0">
> ---
> 
> Let's suppose we want to give a specific style (dark red, underlined) to <i> 
> and <b> elements having @outputclass="emphasis". This may be done as follows:
> 
> ---
>  <xsl:attribute-set name="emphasis_style">
>    <xsl:attribute name="color">maroon</xsl:attribute>
>    <xsl:attribute name="text-decoration">underline</xsl:attribute>
>  </xsl:attribute-set>
> 
>  <xsl:template match="b[@outputclass='emphasis']">
>    <fo:inline xsl:use-attribute-sets="b emphasis_style">
>      <xsl:call-template name="commonAttributes"/>
>      <xsl:apply-templates/>
>    </fo:inline>
>  </xsl:template>
> 
>  <xsl:template match="i[@outputclass='emphasis']">
>    <fo:inline xsl:use-attribute-sets="i emphasis_style">
>      <xsl:call-template name="commonAttributes"/>
>      <xsl:apply-templates/>
>    </fo:inline>
>  </xsl:template>
> ---
> 
> Let's suppose we want to render <boolean state="yes"/> and <boolean 
> state="no"/> as OK/Cancel icons. This may be done as follows:
> 
> ---
>  <xsl:template match="boolean">
>    <fo:external-graphic content-height="16px">
>      <xsl:attribute name="src">
>        <xsl:choose>
>          <xsl:when test="@state eq 'yes'">
>            <xsl:value-of 
> select="'url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+CiAgICA8dGl0bGU+Y2hlY2sgaWNvbjwvdGl0bGU+CiAgICA8ZGVzYz5jaGVjayBpY29uIGZyb20gdGhlIEljb25FeHBlcmllbmNlLmNvbSBHLUNvbGxlY3Rpb24uIENvcHlyaWdodCBieSBJTkNPUlMgR21iSCAod3d3LmluY29ycy5jb20pLjwvZGVzYz4KICAgIDxkZWZzPgogICAgICAgIDxsaW5lYXJHcmFkaWVudCB4MT0iNyIgeTE9IjM0LjUiIHgyPSIzODEuNDI3NyIgeTI9IjQzNy4zMjE1IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImNvbG9yLTEiPgogICAgICAgICAgICA8c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiM3N2RhMjYiLz4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNWJhNjFlIi8+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIGZpbGw9InVybCgjY29sb3ItMSkiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIHN0cm9rZS1saW5lY2FwPSJidXR0IiBzdHJva2UtbGluZWpvaW49Im1pdGVyIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS1kYXNoYXJyYXk9IiIgc3Ryb2tlLWRhc2hvZmZzZXQ9IjAiIGZvbnQtZmFtaWx5PSJub25lIiBmb250LXdlaWdodD0ibm9uZSIgZm9udC1zaXplPSJub25lIiB0ZXh0LWFuY2hvcj0ibm9uZSIgc3R5bGU9Im1peC1ibGVuZC1tb2RlOiBub3JtYWwiPgogICAgICAgIDxwYXRoIGQ9Ik00MzIuNSwzNC41bDc5LDc5bC0zMzQuNSwzMzVsLTE3MCwtMTcwbDc5LjUsLTc5bDkwLjUsOTAuNXoiIGlkPSJjdXJ2ZTAiLz4KICAgIDwvZz4KPC9zdmc+)'"/>
>          </xsl:when>
>          <xsl:otherwise>
>            <xsl:value-of 
> select="'url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+CiAgICA8dGl0bGU+ZGVsZXRlIGljb248L3RpdGxlPgogICAgPGRlc2M+ZGVsZXRlIGljb24gZnJvbSB0aGUgSWNvbkV4cGVyaWVuY2UuY29tIEctQ29sbGVjdGlvbi4gQ29weXJpZ2h0IGJ5IElOQ09SUyBHbWJIICh3d3cuaW5jb3JzLmNvbSkuPC9kZXNjPgogICAgPGRlZnM+CiAgICAgICAgPGxpbmVhckdyYWRpZW50IHgxPSIyOS41IiB5MT0iMjkuNSIgeDI9IjQ0Ni41NTQiIHkyPSI0MTYuNzY1IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImNvbG9yLTEiPgogICAgICAgICAgICA8c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNlZjVjNTEiLz4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjYzQzMTI2Ii8+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIGZpbGw9InVybCgjY29sb3ItMSkiIGZpbGwtcnVsZT0ibm9uemVybyIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIHN0cm9rZS1saW5lY2FwPSJidXR0IiBzdHJva2UtbGluZWpvaW49Im1pdGVyIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS1kYXNoYXJyYXk9IiIgc3Ryb2tlLWRhc2hvZmZzZXQ9IjAiIGZvbnQtZmFtaWx5PSJub25lIiBmb250LXdlaWdodD0ibm9uZSIgZm9udC1zaXplPSJub25lIiB0ZXh0LWFuY2hvcj0ibm9uZSIgc3R5bGU9Im1peC1ibGVuZC1tb2RlOiBub3JtYWwiPgogICAgICAgIDxwYXRoIGQ9Ik0zOTIsMjkuNWw5MC41LDkwLjVsLTEzNiwxMzZsMTM2LDEzNmwtOTAuNSw5MC41bC0xMzYsLTEzNmwtMTM2LDEzNmwtOTAuNSwtOTAuNWwxMzYsLTEzNmwtMTM2LC0xMzZsOTAuNSwtOTAuNWwxMzYsMTM2eiIgaWQ9ImN1cnZlMCIvPgogICAgPC9nPgo8L3N2Zz4=)'"/>
>          </xsl:otherwise>
>        </xsl:choose>
>      </xsl:attribute>
>    </fo:external-graphic>
>  </xsl:template>
> ---
> 
> Complete, working (see attached "dita-sample_pdf.png"), "custom_fo.xsl" 
> attached to this email.
> 
> Now the question is: how to write these custom XSLT templates? Answer: by 
> looking at the corresponding stock templates.
> 
> You'll find all stock templates in folder 
> "XSLUtility_INSTALL_DIR/addon/config/dita/xsl/fo/". For example 
> "XSLUtility_INSTALL_DIR/addon/config/dita/xsl/fo/typographic.xsl" contains 
> the stock template for element <b>:
> 
> ---
>  <xsl:attribute-set name="b">
>    <xsl:attribute name="font-weight">bold</xsl:attribute>
>  </xsl:attribute-set>
> 
>  <xsl:template match="*[contains(@class,' hi-d/b ')]">
>    <fo:inline xsl:use-attribute-sets="b">
>      <xsl:call-template name="commonAttributes"/>
>      <xsl:apply-templates/>
>    </fo:inline>
>  </xsl:template>
> ---
> 
> 
> <1app.png><2edit_transform.png><3customize_fo_xsl.png><4use_custom_fo_xsl.png><custom_fo.xsl><dita_sample_pdf.png>


--
XMLmind FO Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xfc-support

Reply via email to