werD
06-05-2007, 05:04 PM
hello
im attempting to display a list of entries from a logfile. each entry may have a file associated with it.
the doc is structured similar to this
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE logfile [
<!ENTITY flags SYSTEM "Flags.xml">
<!ENTITY files SYSTEM "../Files.xml">
]>
<logfile>
&flags;
&files;
<entries>
<entry id="f27c0c30-e779-4def-9a88-02b6eada8bc8" captain="b5e63d7d-80a2-44a9-a677-f83218d43c56" author="werD" title="Testing Entry Abilities" date="2007-05-07" expires="Never" lastedited="Never" contact="Leadership">
<flags>
<flag param="1">6a89b073-b004-4bcc-bbde-86c17044eb80</flag>
<flag param="0">b252bf3a-e21d-483b-8dec-c2c6b61531ad</flag>
</flags>
<files>
<file id="6b69b071-b103-4bdc-cbce-86c17054db91" />
<file id="6f19b171-c203-4ecd-bcde-86b18054cb92" />
</files>
this <b><i>is</i></b> a test <br />
</entry>
the files entity appears as so
<files>
<file id="6b79b071-b003-4bcc-cbde-86c17054eb90" addedby="werD" lastchanged="2007-05-13" name="File1" caption="This is a link to another page" url="http://localhost/page.aspx" filetype="aspx" />
<file id="6b69b071-b103-4bdc-cbce-86c17054db91" addedby="werD" lastchanged="2007-05-13" name="Large Word Doc" caption="A word document full of stuff" url="files.aspx?q=6b69b071-b103-4bdc-cbce-86c17054db91" type="doc" />
</files>
finally, im using this xsl template to trasnform. it takes in the entry id as a parameter and then should be looping through each file and adding a link to it. I seem to be getting a repeated response though
ie. i receive the first file entry each time. I have a feeling its related to my use of self::node() but im not sure if there is a better way
<xsl:template name="attachedfiles">
<xsl:param name="entryid" />
<ul class="attachedfiles">
<xsl:for-each select="/logfile/entries//entry[@id=$entryid]/files//file">
<xsl:if test="self::node()[@id=/logfile/files//file/@id]">
<li>
<xsl:attribute name="class">
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@type"/>
</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@url"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@caption"/>
</xsl:attribute>
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@name"/>
</xsl:element>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:template>
Id appreciate any insight you could give
im attempting to display a list of entries from a logfile. each entry may have a file associated with it.
the doc is structured similar to this
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE logfile [
<!ENTITY flags SYSTEM "Flags.xml">
<!ENTITY files SYSTEM "../Files.xml">
]>
<logfile>
&flags;
&files;
<entries>
<entry id="f27c0c30-e779-4def-9a88-02b6eada8bc8" captain="b5e63d7d-80a2-44a9-a677-f83218d43c56" author="werD" title="Testing Entry Abilities" date="2007-05-07" expires="Never" lastedited="Never" contact="Leadership">
<flags>
<flag param="1">6a89b073-b004-4bcc-bbde-86c17044eb80</flag>
<flag param="0">b252bf3a-e21d-483b-8dec-c2c6b61531ad</flag>
</flags>
<files>
<file id="6b69b071-b103-4bdc-cbce-86c17054db91" />
<file id="6f19b171-c203-4ecd-bcde-86b18054cb92" />
</files>
this <b><i>is</i></b> a test <br />
</entry>
the files entity appears as so
<files>
<file id="6b79b071-b003-4bcc-cbde-86c17054eb90" addedby="werD" lastchanged="2007-05-13" name="File1" caption="This is a link to another page" url="http://localhost/page.aspx" filetype="aspx" />
<file id="6b69b071-b103-4bdc-cbce-86c17054db91" addedby="werD" lastchanged="2007-05-13" name="Large Word Doc" caption="A word document full of stuff" url="files.aspx?q=6b69b071-b103-4bdc-cbce-86c17054db91" type="doc" />
</files>
finally, im using this xsl template to trasnform. it takes in the entry id as a parameter and then should be looping through each file and adding a link to it. I seem to be getting a repeated response though
ie. i receive the first file entry each time. I have a feeling its related to my use of self::node() but im not sure if there is a better way
<xsl:template name="attachedfiles">
<xsl:param name="entryid" />
<ul class="attachedfiles">
<xsl:for-each select="/logfile/entries//entry[@id=$entryid]/files//file">
<xsl:if test="self::node()[@id=/logfile/files//file/@id]">
<li>
<xsl:attribute name="class">
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@type"/>
</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@url"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@caption"/>
</xsl:attribute>
<xsl:value-of select="/logfile/files//file[@id=self::node()/@id]/@name"/>
</xsl:element>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:template>
Id appreciate any insight you could give