Diazo XSLT and external document only work with a hardcoded path to the document

114 Views Asked by At

So far the only way to load my external document is to hardcode the path. I'd like to be able to use a relative path or variable.

I've created a Diazo rule which transforms content from an external page (called 'footer-columns') and places it in my themed pages.

Version A - This version works (note the hardcoded path):

 <replace css:theme-children=".footer-menu-row">
     <xsl:for-each
       select="document('http://example.com/footer-columns')//*/dl[contains(@class,'portletStaticText')]/dd"
     ><div class="w-col w-col-3">
           <xsl:copy-of select="." />
     </div>
     </xsl:for-each>
      </replace>

Version B - This version does not work:

 <replace css:theme-children=".footer-menu-row">
     <xsl:for-each
       select="document('{$portal_url}/footer-columns')//*/dl[contains(@class,'portletStaticText')]/dd"
     ><div class="w-col w-col-3">
           <xsl:copy-of select="." />
     </div>
     </xsl:for-each>
      </replace>

Version C - absolute path does not work (in fact it returns an error):

 <replace css:theme-children=".footer-menu-row">
     <xsl:for-each
       select="document('/footer-columns')//*/dl[contains(@class,'portletStaticText')]/dd"
     ><div class="w-col w-col-3">
           <xsl:copy-of select="." />
     </div>
     </xsl:for-each>
      </replace>

Version D - relative path does not work (in fact it returns an error):

 <replace css:theme-children=".footer-menu-row">
     <xsl:for-each
       select="document('footer-columns')//*/dl[contains(@class,'portletStaticText')]/dd"
     ><div class="w-col w-col-3">
           <xsl:copy-of select="." />
     </div>
     </xsl:for-each>
      </replace>

For version C and D I get the same error:

AttributeError: 'PersistentResourceDirectory' object has no attribute 'getPhysicalPath'

2

There are 2 best solutions below

0
ebrehault On

You need to provide a nodeset to the document() method. Diazo already sets a variable named diazo-base-document with the proper nodeset.

Try:

select="document('footer-columns', $diazo-base-document)//*/dl[contains(@class,'portletStaticText')"
0
cdw9 On

Could you specify href="/footer-columns" on the replace tag?