cancel
Showing results for 
Search instead for 
Did you mean: 

Find content using an id and idref

kooktroop
Champ in-the-making
Champ in-the-making
I need to be able to find any give piece of XML content using an id/idref within an XML file. This, at the moment, is so I can render an XML file and obtain information required by the XSLT (to present the content properly) from another XML file using an id/idref. As I am familiar with XSLT let me explain it on those terms;

Let’s take two xml files:

<!– Content.xml –>

<content>
<name>Content</name>
<contentreference idref=”referenced_content” />
</content>
<!– Referenced Content.xml –>

<content id=”referenced_content”>
            <name>Referenced Content</name>
</content>

I want to be able to do something like

<!– output.xslt –>

<xsl:template match="content">
<xsl:value-of select="name" /><br />
<xsl:variable name="referencedId" select="contentreference/@idref" />
<xsl:value-of select="/content[@id=$referencedId]/name" />
</xsl:template>

and end up with:

<!– output.html –>
<html>
<body>
Content<br /> <!– taken from Content.xml –>
Referenced Content <!– taken from Referenced Content.xml –>
</body>
</html>

In Alfresco, my understanding is that we could store everything in one directory with the id as the filename, then just use Alfresco’s XML loading function: parseXMLDocument() to do something like <xsl:value-of select=”parseXMLDocument( contentreference/@idref )/name” /> and we would get the output of output.xml in the above example.

The only downfall here is that from the editing user's point of view (in our case) there would be over 1,000 content items with filenames like pu_ae_act-idalt_tsk-idalt or rm_ft_phs-projini_stage-projini in one directory.

I don't want to store everything in the one xml file because this makes editing difficult from the users point of view due to it being in one massive file that would be difficult to search and edit in Alfresco. Remember there are over 1,000 items with sometimes over 10 different input fields.

Is there a better solution? I could go with the parseXMLDocument() and id named files but that doesn't seem elegant or user friendly. Should I be using FreeMarker?
2 REPLIES 2

arielb
Champ in-the-making
Champ in-the-making
we certainly do not have a good solution for you right now.  what you're looking for is search for structured xml content - which is an interesting and hard problem.  the best solution i have for you - which is not a great solution by any means is to use the parseXMLDocuments(form_name) function to retrieve all documents created by that form and create your own hash of idrefs in xsl.  since this processing time is all at page creation - it only has an impact on your dev environment (page generation will be slow) - but your production environment will not have any impact from this.  please file a feature request for this at http://issues.alfresco.com

kooktroop
Champ in-the-making
Champ in-the-making
I am going to try out;

In Alfresco, my understanding is that we could store everything in one directory with the id as the filename, then just use Alfresco’s XML loading function: parseXMLDocument() to do something like <xsl:value-of select=”parseXMLDocument( contentreference/@idref )/name” /> and we would get the output of output.xml in the above example.

The only downfall here is that from the editing user's point of view (in our case) there would be over 1,000 content items with filenames like pu_ae_act-idalt_tsk-idalt or rm_ft_phs-projini_stage-projini in one directory.

Failing that, I am going to try out your suggestion. Thanks for the response - I am really looking forward to seeing what kind of solution you guys come up with.