Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Scott Meikle 28 posts 228 karma points
    Feb 11, 2015 @ 15:53
    Scott Meikle
    0

    XSL Attribute Sets - Supported ?

    Hello,

    I am having a problem getting basic XSL attribute sets working. My simplified example :

    <xsl:attribute-set name="foo">
        <xsl:attribute name="border">1px solid black</xsl:attribute>
        <xsl:attribute name="z-index">0</xsl:attribute>
        <xsl:attribute name="position">absolute</xsl:attribute>
        <xsl:attribute name="left">0.58in</xsl:attribute>
        <xsl:attribute name="top">2.56in</xsl:attribute>
        <xsl:attribute name="height">2.35in</xsl:attribute>
        <xsl:attribute name="width">3.45in</xsl:attribute>
    </xsl:attribute-set>
    
    <fo:block-container xsl:use-attribute-sets="foo">
    </fo:block-container>
    

    This should put a rectangle with a black border at the given position on the page. However, on my output page the styling attributes aren't applied and consequently nothing appears.

    On the other hand, when I set the attributes directly on the fo:block-container element like so :

    <fo:block-container border="1px solid black" z-index="0"
                        position="absolute"
                        left="0.58in" top="2.56in"
                        height="2.35in" width="3.45in">
    </fo:block-container>
    

    ...the output displays as expected.

    With regards to the PDF Creator, am I missing something obvious or are XSL attribute sets not supported? I would be most grateful if someone could knock up a simple working example to get me going.

    Kind regards,

    Scott

    P.S. my code is in a Razor macro directly within an Umbraco document template, not in an XSLT macro, if that makes any difference.

  • Kate BP 5 posts 25 karma points
    May 27, 2015 @ 14:48
    Kate BP
    0

    After 3 months I'm unlikely to get a response, but does anyone know if attribute sets are supported? I'm having the exact same problem.

  • Mehul Gajjar 48 posts 172 karma points
    May 27, 2015 @ 15:35
    Mehul Gajjar
    0

    Hi Scott,

    Yes you can set attribute in your xslt like below and also set out put method as "html"

     <xsl:output method="html" omit-xml-declaration="yes"/>
    
    <xsl:attribute-set name="table-attrs">
        <xsl:attribute name="style">
            border: 1px solid red;
        </xsl:attribute>
    </xsl:attribute-set>
    
    
    <table xsl:use-attribute-sets="table-attrs">
    
        do some code
    
    </table>
    

    Hope it will help you

    Regrds,

    Mehul Gajjar.

  • Kate BP 5 posts 25 karma points
    Jun 01, 2015 @ 10:18
    Kate BP
    0

    As far as I can see, the example about does not work with the xsl-fo used by the PDF creator?

    I can't even get the table to display when I insert it into my code, ignoring the styling issue. I am currently outputting the page content using FO-BLOCK and FO_INLINE.

    From the top of the file:

    <?xml version="1.0" encoding="UTF-8" ?>
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using FergusonMoriyama.Pdf
    @using System.Xml
    @using umbraco.IO
    @
        Layout = null;
    
        Response.ContentType = "text/xsl";
        Response.AppendHeader("X-Pdf-Render","true"); //-- Comment out to show generated XML</p>
    
        // -- Uncomment this to force the browser to download the PDF.
        // Response.AppendHeader("X-Pdf-Force-Download","darren.pdf");
    }
     <xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format" version="2.0" 
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    @* This assigns attributes to attribute-set(s) [classes] *@
    <xsl:attribute-set name="kate-test">
    <xsl:attribute name="fname">Arial</xsl:attribute>
      <xsl:attribute name="size">64px</xsl:attribute>
      <xsl:attribute name="color">red</xsl:attribute>
    </xsl:attribute-set>
        <xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ibex="http://www.xmlpdf.com/2003/ibex/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
               @* Sets standard PDF Metadata *@
             <ibex:properties
           title="@CurrentPage.Name"
           author="@CurrentPage.WriterName"
           subject=""
           creator="PDF Creator for Umbraco" />
              <fo:layout-master-set>
                <fo:simple-page-master master-name="master" page-width="210mm" page-height="297mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
                  <fo:region-body margin-top="1.5cm" margin-bottom="1.5cm" column-count="2" column-gap="0.5cm"/>
                  <fo:region-before region-name="header" extent="3cm"/>
                  <fo:region-after region-name="footer" extent="1.5cm"/>
                </fo:simple-page-master>
              </fo:layout-master-set>
              
               @* Main content starts within page sequence *@
               <fo:page-sequence master-reference="master">
    
            @* Document header *@
            <fo:flow flow-name="header">
              <fo:block>
                <fo:inline font-family="Arial" font-size="23pt" color="#3399ff">
                  @CurrentPage.Name
                </fo:inline>
              </fo:block>
     <fo:block xsl:use-attribute-sets="kate-test">
     Block rocking beats
     </fo:block> 
            </fo:flow>
    

    //----- fie continues to file footer, body and helper functions ------

    </xsl:template>
    </xsl:stylesheet>
    

    Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies