Re: Orbeon XSLT Problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Orbeon XSLT Problem

Alessandro Vernet
Administrator
Jim,

This is an interesting case, because you have a template <xsl:template  
match="/sidebar">, but that sidebar is not a sidebar of the document  
fed to the stylesheet, so I am not surprised it doesn't matches on the  
root element of document('Sidebar-Contents.xml')". What if you change  
that template to just say <xsl:template match="sidebar"> (without the  
slash). Would that work?

Alex

On Thu, Oct 16, 2008 at 9:51 AM, Jim Logan <[hidden email]>  
wrote:

>
> I'm having a terrible time integrating my own XSLT with the Orbeon  
> XSLT.
> This template is what seems to be making life difficult, and I don't  
> know
> how to work around it:
>
>    <!-- Simply copy everything that's not matched -->
>    <xsl:template match="@*|node()" priority="-2">
>        <xsl:copy>
>            <xsl:apply-templates select="@*|node()"/>
>        </xsl:copy>
>    </xsl:template>
>
> The XSLT file that has this template includes my XSLT, which gets a  
> lower
> precedence. If I comment this template out, my XSLT works, but then  
> the form
> breaks.
>
> My understanding is that templates in imported files always get the  
> lowest
> precedence. I've tried moving this template out to another file and
> importing it, but it still seems to get a higher priority than the  
> templates
> in my imported file.
>
> My XSLT file looks like this, with the parts that seem to be getting
> affected boldfaced:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="2.0"
>
> xmlns:mdp="http://www.modeldriven.org/2007/schema/ModelDrivenProfile.xsd 
> "
>    xmlns:rdf-schema="http://www.w3.org/2000/01/rdf-schema#"
>    xmlns:owl="http://www.w3.org/2002/07/owl#"
>    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
> xmlns:DefaultViewpoint="http://www.modeldriven.org/2008/ArchitectureOntology/DefaultViewpoint.owl# 
> "
>
> xmlns:Actors="http://www.modeldriven.org/2008/ArchitectureOntology/Actors.owl# 
> ">
>
>    <xsl:variable name="sidebar" select="document('Sidebar-
> Contents.xml')"
>        as="document-node()"/>
>
>    <xsl:template match="/">
>        <html>
>            <head>
>                <title>
>                    <xsl:call-template name="title"/>
>                </title>
>                <xsl:call-template name="stylesheet"/>
>                <xsl:call-template name="scripts"/>
>            </head>
>            <body>
>                <xsl:call-template name="onload"/>
>                <table width="100%" height="100%">
>                    <tbody>
>                        <tr>
>                            <td valign="top" width="10%">
>                                <xsl:apply-templates
> select="$sidebar/sidebar"/>
>                            </td>
>                            <td valign="top" id="body">
>                                <xsl:call-template name="body"/>
>                            </td>
>                        </tr>
>                    </tbody>
>                </table>
>            </body>
>        </html>
>    </xsl:template>
>
>    <!--
>        Other XSLT files are expected to import this file and  
> override these
> named
>        templates.
>    -->
>    <xsl:template name="title">
>        <xsl:value-of select="*/*/rdf-schema:label"/>
>    </xsl:template>
>
>    <xsl:template name="stylesheet">
>        <link rel="stylesheet" type="text/css" href="style.css"/>
>    </xsl:template>
>
>    <xsl:template name="scripts">
>        <script type="text/javascript" src="decode.js"/>
>    </xsl:template>
>
>    <xsl:template name="body">
>        <form>
>            <input type="button" value="Edit"
>
> onClick="parent.location='http://localhost:8080/orbeon/xforms-hello/Html-Editor' 
> "/>
>        </form>
>        <h1>
>            <xsl:value-of select="*/*/rdf-schema:label"/>
>        </h1>
>        <span id="encoded">
>            <xsl:value-of select="*/*/rdf-schema:description"/>
>        </span>
>    </xsl:template>
>
>    <xsl:template name="onload">
>        <xsl:attribute name="onload">decode()</xsl:attribute>
>    </xsl:template>
>
>
>
>    <xsl:template match="/sidebar">
>        <xsl:apply-templates select="logo"/>
>        <br/>
>        <xsl:apply-templates select="search-site"/>
>        <ul>
>            <xsl:apply-templates select="link"/>
>        </ul>
>    </xsl:template>
>
>    <xsl:template match="/sidebar/logo">
>        <span id="logo">
>            <xsl:choose>
>                <xsl:when test="@link != ''">
>                    <a>
>                        <xsl:attribute name="href">
>                            <xsl:value-of select="@link"/>
>                        </xsl:attribute>
>                        <img>
>                            <xsl:attribute name="src">
>                                <xsl:value-of select="."/>
>                            </xsl:attribute>
>                        </img>
>                    </a>
>                </xsl:when>
>                <xsl:otherwise>
>                    <img>
>                        <xsl:attribute name="src">
>                            <xsl:value-of select="."/>
>                        </xsl:attribute>
>                    </img>
>                </xsl:otherwise>
>            </xsl:choose>
>        </span>
>    </xsl:template>
>
>    <xsl:template match="/sidebar/search-site">
>        <form method="GET" id="search"
> action="http://www.google.com/custom">
>            <span style="white-space: nowrap"> Search: <input  
> type="text"
> name="q"
>                    size="10" maxlength="255" value=""/>
>                <input id="submit-button" type="submit" name="sa"
> value="Go"/>
>            </span>
>            <input type="hidden" name="sitesearch">
>                <xsl:attribute name="value">
>                    <xsl:value-of select="."/>
>                </xsl:attribute>
>            </input>
>        </form>
>    </xsl:template>
>
>    <xsl:template match="/sidebar/link">
>        <li>
>            <a>
>                <xsl:attribute name="href">
>                    <xsl:value-of select="."/>
>                </xsl:attribute>
>                <xsl:value-of select="@name"/>
>            </a>
>        </li>
>    </xsl:template>
> </xsl:stylesheet>
>
> The hacked Orbeon XSLT looks like this, with the parts related to my  
> XSLT
> boldfaced:
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:f="http://orbeon.org/oxf/xml/formatting"
>    xmlns:xhtml="http://www.w3.org/1999/xhtml"
>    xmlns:xforms="http://www.w3.org/2002/xforms"
>    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>    xmlns:version="java:org.orbeon.oxf.common.Version">
>
>    <!-- XML formatting -->
>    <xsl:import href="oxf:/ops/utils/formatting/formatting.xsl"/>
>    <xsl:import href="EKB-Sidebar.xsl"/>
>
>    <!-- This contains some useful request information -->
>    <xsl:variable name="request" select="doc('input:request')"
>        as="document-node()"/>
>
>    <!-- List of applications -->
>    <xsl:variable name="applications" select="doc('../apps-list.xml')"
>        as="document-node()"/>
>    <!-- Current application id -->
>    <xsl:variable name="current-application-id"
>        select="tokenize(doc('input:request')/*/request-path, '/')[2]"
>        as="xs:string"/>
>    <!-- Source viewer application id if relevant -->
>    <xsl:variable name="is-source-viewer"
>        select="$current-application-id = 'source-viewer'"  
> as="xs:boolean"/>
>    <xsl:variable name="source-viewer-application-id"
>        select="if ($is-source-viewer) then
> tokenize(doc('input:request')/*/request-path, '/')[3] else ()"
>        as="xs:string?"/>
>    <!-- Try to obtain a meaningful title for the example -->
>    <xsl:variable name="title"
>        select="if (/xhtml:html/xhtml:head/xhtml:title != '')
>                                       then
> /xhtml:html/xhtml:head/xhtml:title
>                                       else if
> (/xhtml:html/xhtml:body/xhtml:h1)
>                                            then
> (/xhtml:html/xhtml:body/xhtml:h1)[1]
>                                            else '[Untitled]'"
>        as="xs:string"/>
>    <!-- Orbeon Forms version -->
>    <xsl:variable name="orbeon-forms-version"  
> select="version:getVersion()"
>        as="xs:string"/>
>
>    <!-- Simply copy everything that's not matched -->
>    <xsl:template match="@*|node()" priority="-2">
>        <xsl:copy>
>            <xsl:apply-templates select="@*|node()"/>
>        </xsl:copy>
>    </xsl:template>
>
>    <xsl:template name="title">
>        GSA OsEra Configuration Management - <xsl:value-of
>            select="$title"/>
>    </xsl:template>
>
>    <xsl:template name="stylesheet">
>        <link rel="stylesheet" type="text/css" href="style.css"/>
>        <link rel="stylesheet" href="/config/theme/orbeon.css"
>            type="text/css" media="all"/>
>        <xsl:for-each
>            select="/xhtml:html/xhtml:head/(xhtml:meta | xhtml:link |
> xhtml:style | xhtml:script)">
>            <xsl:element name="xhtml:{local-name()}"
> namespace="{namespace-uri()}">
>                <xsl:copy-of select="@*"/>
>                <xsl:apply-templates/>
>            </xsl:element>
>        </xsl:for-each>
>        <xhtml:meta name="generator"
>            content="Orbeon Forms {$orbeon-forms-version}"/>
>        <!-- Favicon -->
>        <xhtml:link rel="shortcut icon"
> href="/ops/images/orbeon-icon-16.ico"/>
>        <xhtml:link rel="icon" href="/ops/images/orbeon-icon-16.png"
>            type="image/png"/>
>    </xsl:template>
>
>    <xsl:template name="scripts">
>    </xsl:template>
>
>    <xsl:template name="body">
>        <!-- Copy body attributes -->
>        <xsl:apply-templates select="/xhtml:html/xhtml:body/@*"/>
>
>        <!--                                <xhtml:a
> href="http://osera.modeldriven.org" f:url-norewrite="true">
>            <xhtml:img f:url-norewrite="false" width="199" height="42"
>            style="border: 0 white; margin-left: 1em; margin-top:  
> 0.2em;
> margin-bottom: 0.4em"
>            src="http://www.gsa.gov/gsa/images/gsa_logo.gif"  
> alt='home'/>
>            </xhtml:a>
>        -->
>        <xhtml:div class="maincontent">
>            <!-- Title -->
>            <xhtml:h1>
>                <!-- Title -->
>                <xsl:value-of select="$title"/>
>            </xhtml:h1>
>            <!-- Body -->
>            <xhtml:div id="mainbody">
>                <xsl:apply-templates
> select="/xhtml:html/xhtml:body/node()"/>
>            </xhtml:div>
>        </xhtml:div>
>    </xsl:template>
>
>    <xsl:template name="onload">
>    </xsl:template>
> </xsl:stylesheet>
>
> Can anyone help please?
>
> Thanks,
> -Jim
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Orbeon XSLT Problem

Jim Logan-3
Alessandro Vernet wrote:
Jim,

This is an interesting case, because you have a template <xsl:template match="/sidebar">, but that sidebar is not a sidebar of the document fed to the stylesheet, so I am not surprised it doesn't matches on the root element of document('Sidebar-Contents.xml')". What if you change that template to just say <xsl:template match="sidebar"> (without the slash). Would that work?

Alex
Alex,

That's actually what I started with. I changed it to be more specific to see if it helped. I don't understand how the low-priority template can even see the document('Sidebar-Contents.xml')!

Thanks,
-Jim



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws