Orbeon XSLT Problem

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

Orbeon XSLT Problem

Jim Logan-3

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
Reply | Threaded
Open this post in threaded view
|

RE: Orbeon XSLT Problem

Ryan Puddephatt-3

Have you used <xsl:include to import at the same precedence?!

 

-----------------------------------------------

Ryan Puddephatt

FIX Developer

Fidessa LatentZero

1 Alfred Place

London WC1E 7EB

Office: +44 (0) 20 7462 4200

Direct: +44 (0) 20 7323 6112

Blackberry: +44 (0) 79 8539 2458

Fax: +44 (0) 20 7462 4242

Email: [hidden email]

Web: http://www.latentzero.com

 

From: Jim Logan [mailto:[hidden email]]
Sent: 16 October 2008 17:52
To: [hidden email]
Subject: [ops-users] Orbeon XSLT Problem

 


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



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


_______________________________________________________________________
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

_____________________________________________________________________
This e-mail has been scanned for viruses by Verizon Business Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com


--
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
Ryan Puddephatt wrote:

Have you used <xsl:include to import at the same precedence?!

Yes, I did try that and got the same result, which was unexpected!

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
Reply | Threaded
Open this post in threaded view
|

Re: Re: RE: Orbeon XSLT Problem

Jim Logan-3
Jim Logan wrote:
Ryan Puddephatt wrote:

Have you used <xsl:include to import at the same precedence?!

Yes, I did try that and got the same result, which was unexpected!

Thanks,
-Jim

I did get something to work, although I don't know why it works. I moved the template matching "@*|node()" into the included XSLT file. That seems to work without bothering my other uses of the XSLT.

BUT...

Things are still not working quite right because no CSS files seem to be loading. I've tried just the file name, I've tried prefixing the file name with "oxf:/config/", and I've tried prefixing the file name with "/config/". Any other ideas?

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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: RE: Orbeon XSLT Problem

Alessandro Vernet
Administrator
Jim,

On Thu, Oct 16, 2008 at 12:20 PM, Jim Logan <[hidden email]> wrote:
> Things are still not working quite right because no CSS files seem to be
> loading. I've tried just the file name, I've tried prefixing the file name
> with "oxf:/config/", and I've tried prefixing the file name with "/config/".
> Any other ideas?

CSS are not loaded by the browser? Are they linked in the generated
HTML? Is the link what you would expect it to be? I am not sure we have
enough information at this point to be able to help.

Alex
--
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: Re: Re: RE: Orbeon XSLT Problem

Jim Logan-3
Alessandro Vernet wrote:

> Jim,
>
> On Thu, Oct 16, 2008 at 12:20 PM, Jim Logan <[hidden email]>
> wrote:
>> Things are still not working quite right because no CSS files seem to be
>> loading. I've tried just the file name, I've tried prefixing the file
>> name
>> with "oxf:/config/", and I've tried prefixing the file name with
>> "/config/".
>> Any other ideas?
>
> CSS are not loaded by the browser? Are they linked in the generated
> HTML? Is the link what you would expect it to be? I am not sure we
> have enough information at this point to be able to help.
>
> Alex
It's hard to tell what's going on. I would deduce from your response
that these URLs shouldn't get rewritten and the browser should load the
CSS. I expected them to get rewritten. That may be why I'm having trouble.

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