XSLT Include

Maurice's Avatar

Maurice

09 Jun, 2016 10:42 PM

Hi I'm currently trying to include another xslt stylesheet and I always get the error:

"An error occurred while rendering asset preview: javax.xml.transform.TransformerException: org.jdom.JDOMException: Exception in startElement: Had IO Exception with stylesheet file: write-pod"

original.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:include href="write-pod" />
    <xsl:template match="system-index-block">
        <xsl:apply-templates select="calling-page/system-page/system-data-structure"/>
    </xsl:template>
    <xsl:template match="system-data-structure">
        <div class="slab" id="forwardtogether" style="padding:1.5rem 0">
            <div class="row">
                <div class="columns small-12 text-center">
                    <picture>
                        <source alt="Forward Together" media="(min-width: 701px)" srcset="img/homepage/forward/forwardtogether_logo_crop.png"/>
                        <source media="(max-width: 700px)" srcset="img/homepage/forward/forwardtogether_logo_home_vert_crop.png"/>
                        <img alt="forward together" height="168" src="img/homepage/forward/forwardtogether_logo_home_vert_crop.png" width="1072"/>
                    </picture>
                </div>
                <div class="clearfix"></div>
                <!-- MODALS SECTION -->
                <div class="modals">
                    <xsl:call-template name="write-modal">
                        <xsl:with-param name="type">
                            <xsl:text>preparing</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="level">
                            <xsl:text>1</xsl:text>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:call-template name="write-modal">
                        <xsl:with-param name="type">
                            <xsl:text>building</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="level">
                            <xsl:text>2</xsl:text>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:call-template name="write-modal">
                        <xsl:with-param name="type">
                            <xsl:text>solving</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="level">
                            <xsl:text>3</xsl:text>
                        </xsl:with-param>
                    </xsl:call-template>
                </div>
            </div>
        </div>
    </xsl:template>
    <!-- WRITING THE MODAL CONTENT -->
    <xsl:template name="write-modal">
        <xsl:param name="type"/>
        <xsl:param name="level"/>
            <div aria-hidden="true" class="reveal-modal small" data-reveal="" id="{$type}" role="dialog">
                <xsl:for-each select="pod">
                    <xsl:if test="position() = $level">
                        <p><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></p>
                        <div class="flex-video">
                            <iframe allowfullscreen="" frameborder="0" height="395" src="{video-url}" width="700"></iframe>
                        </div>
                        <div class="button-collapse-stack">
                            <div class="columns small-12 medium-6">
                                <a class="button expand hp-button hp-outline-button hp-outline-button1" href="{destination}">LEARN MORE</a>
                            </div>
                            <div class="columns small-12 medium-6">
                                <a class="button expand hp-button hp-fill-button hp-fill-button1" href="https://bastion.csusm.edu/giving/">GIVE NOW</a>
                            </div>
                        </div>
                        <a aria-label="Close" class="close-reveal-modal">&#215;</a>
                    </xsl:if>
                </xsl:for-each>
            </div>
    </xsl:template>
</xsl:stylesheet>

write-pod.xsl

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:template match="system-data-structure">
        <xsl:call-template name="write-pod">
            <xsl:with-param name="type">
                <xsl:text>preparing</xsl:text>
            </xsl:with-param>
            <xsl:with-param name="level">
                <xsl:text>1</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <!-- END OF POD 1 -->
        <xsl:call-template name="write-pod">
            <xsl:with-param name="type">
                <xsl:text>building</xsl:text>
            </xsl:with-param>
            <xsl:with-param name="level">
                <xsl:text>2</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <!-- END OF POD 2 -->
        <xsl:call-template name="write-pod">
            <xsl:with-param name="type">
                <xsl:text>solving</xsl:text>
            </xsl:with-param>
            <xsl:with-param name="level">
                <xsl:text>3</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <!-- END OF POD 3 -->
    </xsl:template>
    <xsl:template name="write-pod">
        <xsl:param name="type"/>
        <xsl:param name="level"/>
        <div class="small-12 large-4 columns">
            <div class="hp-circle-block text-center">
                <xsl:for-each select="pod">
                    <xsl:if test="position() = $level">
                        <xsl:element name="div">
                            <xsl:attribute name="class">
                                <xsl:value-of select="concat('forward-image second-effect ', $type)"/>
                            </xsl:attribute>
                        </xsl:element>
                        <p>
                            <a data-reveal-id="{$type}" href="#">
                                <img alt="{alt}" class="{$type}" height="350" src="{img/path}" width="350"/>
                            </a>
                        </p>
                        <div class="mask"></div>
                        <div class="content">
                            <a class="info" href="#">
                                <xsl:attribute name="data-reveal-id">
                                    <xsl:value-of select="$type"/>
                                </xsl:attribute>
                            </a>
                        </div>
                        <div class="forward-text-container">
                            <div class="forward-text">
                                <xsl:value-of select="pod-quote"/>
                                <br/>
                                <span>
                                    <xsl:value-of select="author"/>
                                </span>
                            </div>
                            <p>
                                <a class="button expand hp-button hp-fill-button hp-fill-button1" data-reveal-id="{$type}" href="{destination}">
                                    <xsl:value-of select="button"/>
                                </a>
                            </p>
                        </div>
                    </xsl:if>
                </xsl:for-each>
            </div>
        </div>
    </xsl:template>
</xsl:stylesheet>
  1. 1 Posted by Ryan Griffith on 10 Jun, 2016 12:20 PM

    Ryan Griffith's Avatar

    Hi Maurice,

    When you have a moment, please also attach sample XML you are applying to this Format so we can do some local testing.

    Thanks!

  2. 2 Posted by Wing Ming Chan on 10 Jun, 2016 01:02 PM

    Wing Ming Chan's Avatar

    Hi Maurice,

    Two things:
    1. You need to include the site name in the xsl:include element like this:

    <xsl:include href="site://_common/formats/Upstate/library/news-processing"/>
    
    2. You may want to introduce namespaces in your library code and the stylesheets using the library code

    Also a suggestion for Hannon Hill. Users should be taught on how to build and use library code: XSLT, Velocity, and web services.

    Wing

  3. 3 Posted by Maurice on 13 Jun, 2016 04:11 PM

    Maurice's Avatar

    Hello Dr. Wing,
    After i tried linking the xslt like what you said I got this error:

    An error occurred while rendering asset preview: Had IO Exception with stylesheet file: csusm/_homeassets/site://_homeassets/write-pod

    It looks like I do not have to include the site and just add the name of the XSLT.

  4. 4 Posted by Maurice on 13 Jun, 2016 04:13 PM

    Maurice's Avatar

    I attached the XML sample

  5. Support Staff 5 Posted by Tim on 13 Jun, 2016 04:18 PM

    Tim's Avatar

    Maurice,

    This error:

    An error occurred while rendering asset preview: Had IO Exception with stylesheet file:
    
    generally means that the system can't find the stylesheet you're referencing. You need to make sure that you use the full path to that Format/stylesheet when you're writing that include statement. If the Format you're referencing is in another Site, you'll need to use the site notation as Wing mentioned.

    Can you provide a screen shot showing the location of this Format you're attempting to reference? Once we can determine which Site it is in along with the directory it's in, someone here can help you with that include statement.

  6. 6 Posted by Maurice on 13 Jun, 2016 04:31 PM

    Maurice's Avatar

    Hello Tim, I have the file in global and not in a site.

  7. Support Staff 7 Posted by Tim on 13 Jun, 2016 04:40 PM

    Tim's Avatar

    Thanks for the screen shot, Maurice. Is write-pod in the same Folder as this forward Block? If so, try changing your include to:

    <xsl:include href="/csusm/_homeassets/write-pod"/>
    
    and let me know if that allows you to save.
  8. 8 Posted by Wing Ming Chan on 13 Jun, 2016 05:57 PM

    Wing Ming Chan's Avatar

    Since Global is going away soon, why not move everything out of Global into a site?

    Wing

  9. Tim closed this discussion on 29 Jun, 2016 02:29 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM