AnsweredAssumed Answered

Find content using an id and idref

Question asked by kooktroop on Mar 6, 2007
Latest reply on Mar 6, 2007 by kooktroop
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 –>

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

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

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" />

and end up with:

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

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?