AnsweredAssumed Answered

parseXMLDocument and Rendering Engine Template Woes

Question asked by kooktroop on Apr 4, 2007
Latest reply on Apr 5, 2007 by kooktroop
What I am trying to do is read an element (pm:deliverable/pm:name) from another XML file in Alfresco. The other file is specified by a ref element of type xs:anyURI.

I'm having problems with parseXMLDocument and the rendering engine templates.

When I comment out the parseXMLDocument function/section the following stylesheet renders the html just fine. When I include parseXMLDocument the resulting html is just blank.


<?xml version="1.0" encoding="UTF-8" ?>
<!–
    Document   : description.xsl
    Created on : 28 March 2007
    Author     : Scott Middleton
    Description:
   
    This stylesheet transforms the description section of a Process Unit.
–>
<xsl:stylesheet version="2.0"
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:pr="http://www.alfresco.org/alfresco/pr"
                xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
                xmlns:mt="http://www.objectconsulting.com.au/mentor/mt"
                xmlns:pm="http://www.processmentor.com"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:alf="http://www.alfresco.org"
                >

  <xsl:output method="html"></xsl:output>

  <xsl:template match="/">
    <xsl:apply-templates select="pm:processunit"/>
  </xsl:template>

  <xsl:template match="pm:processunit">
    <h1>Deliverables</h1>
   
    <xsl:choose>
        <xsl:when test="pm:deliverables/pm:overview">
            <p><b>Overview</b></p>
            <xsl:value-of select="pm:deliverables/pm:overview" disable-output-escaping="yes" />
        </xsl:when>
      <xsl:otherwise>
        <p>
          The following are deliverables for the <xsl:value-of select="pm:name" /> Process Unit:
        </p>   
      </xsl:otherwise>
    </xsl:choose>
   
    <xsl:apply-templates select="pm:deliverables/pm:deliverablereference" />
  </xsl:template>

  <xsl:template match="pm:deliverablereference">
    <p>Ref: <xsl:value-of select="pm:ref" /></p>
    <!–
           pm:ref is something like "/content/xml/Somefile.xml"
           Note: this file does exist!
    –>

    <!– if i comment this 'if' and its contents out then there is output –>
    <xsl:if test="pm:ref">
        <xsl:variable name="deliverableRef" select="pm:ref" />
        <xsl:variable name="deliverable" select="alf:parseXMLDocument( $deliverableRef )" />

        <p>
            <xsl:if test="$deliverable">
<xsl:value-of select="$deliverable/pm:name" />
            </xsl:if>
        </p>   
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>

I've tried replacing parseXMLDocument with document(), I've tried matching as much as possible to the sample. The sample works just fine. I know that the uri for the file I am trying to access is valid because when I comment out parseXMLDocument and just do <xsl:value-of select="pm:ref" /> the value looks fine. I've just run out of things to try.

Any help would be much appreciated!

Outcomes