cancel
Showing results for 
Search instead for 
Did you mean: 

parseXMLDocument and Rendering Engine Template Woes

kooktroop
Champ in-the-making
Champ in-the-making
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!
3 REPLIES 3

kooktroop
Champ in-the-making
Champ in-the-making
I've just realised my console window is giving me the following:


file:///C:/Alfresco/dummy.xsl; Line #0; Column #0; javax.xml.transform.Transform
erException: unable to create uri http://preview.admin.processmentor.www--sandbo
x.10-8-8-117.ip.alfrescodemo.net:8180/content/xml/deliverables/Application Model
.xml
file:///C:/Alfresco/dummy.xsl; Line #0; Column #0; java.lang.NullPointerException

arielb
Champ in-the-making
Champ in-the-making
what you're doing looks reasonable.  is the virtualization server running and does this url work? http://preview.admin.processmentor.www--sandbo
x.10-8-8-117.ip.alfrescodemo.net:8180/content/xml/deliverables/Application Model.xml.

if so - can you try a file name without spaces and see what happens - this could be an url encoding issue.  if none of this works - please file an issue in jira.

kooktroop
Champ in-the-making
Champ in-the-making
I've tried one without spaces - it works fine.

I've also tried:


<xsl:variable name="deliverableRef" select="replace(pm:ref,' ','%20')" />

I've submitted a bug into JIRA, http://issues.alfresco.com/browse/WCM-427