cancel
Showing results for 
Search instead for 
Did you mean: 

problem with document()

timlterry
Champ in-the-making
Champ in-the-making
I'm having some trouble with this code
<ul>
<xsl:for-each select="document('news1.xml')/items/link-text">
<li><xsl:value-of select="." disable-output-escaping="yes"/></li>
</xsl:for-each>
</ul>

The XSL file containing this code and the news1.xml file containing the link-text items I want to get are in the same directory.  The code works ok when I preview the XSL in Dreamweaver, but it totally fails (there is not HTML at all) when I create HTML from this XLS file in Alfresco.

I've replaced the code above with
<xsl:value-of select="document('news1.xml')"/> to see what happens.  Again, works in Dreamweaver but completely fails when I create HTML in Alfresco.

I'm stumped.  What I'm trying to do is have this file tied to a XSD style sheet that codes the body of the page, and then use the code above to get content from a different XML file that contains all of the news items.

Thanks for any assistance you might be able to provide.
4 REPLIES 4

kvc
Champ in-the-making
Champ in-the-making
That should work.  One of our developer will be looking into this.

In the meantime, you can also use parseXMLDocuments in place of this to get this working immediately.

We'll update you in the next day or so.


Kevin

timlterry
Champ in-the-making
Champ in-the-making
Sorry, I'm really new to this. 

As far as I can tell the syntax should be
<ul>
<xsl:for-each select="parseXMLDocuments("news1", "/items/link-text")">
<li><xsl:value-of select="." disable-output-escaping="yes"/></li>
</xsl:for-each>
</ul>

but I'm getting an error

SAXParseException: Expected whitespace (au-with-news-test.xsl, line 148, column 42)

When I try to preview the page in Dreamweaver.

kvc
Champ in-the-making
Champ in-the-making
Yes, you will get an error when previewing in DreamWeaver, as parseXMLDocuments relies on our virtualization server to execute the code for this contained within the user's sandbox.

What you can do to get to work in DreamWeaver is point DreamWeaver to the virtualization server URL to your user's sandbox.  Then it should preview properly in DreamWeaver as well.


Kevin

timlterry
Champ in-the-making
Champ in-the-making
It took a lot of experimentation, but I got this working with

<ul>
<xsl:for-each select="alfSmiley TonguearseXMLDocuments('news', '')">
<h2><xsl:value-of select="heading"/></h2>
<xsl:for-each select="news-item">
<li><xsl:value-of select="." disable-output-escaping="yes"/></li>
</xsl:for-each>
</xsl:for-each>
</ul>

The "alf" bit was critical.  My xml document looks like

<news>
<heading> XXXX</heading>
<news-item>XXXXXX</news-item>
</news>

The code says look in the current directory for any documents that were created by the News web form.  If you find any, parse them out and look for the heading and the list items.  Apply a <H2> to the heading and make all of the list-items into a list.

It seems to work well.  

My next question is - When I change the news XML instance file (the one with the data in it), how do I get Alfresco to push the change to pages that are referencing my news XML instance file?