From: Martin H. <m1...@sn...> - 2006-03-29 22:51:06
|
> So, if I want the title field to be searchable in full text, in metadata, > and > be able to sort on it, I need 3 copies, right? Exactly. Something like this? > > <xsl:template match=3D"eadpath" mode=3D"inmeta"> > <xsl:for-each select=3D"*"> > <xsl:element name=3D"{name()}"> > <xsl:attribute name=3D"xtf:meta" select=3D"'true'"/> > <xsl:copy-of select=3D"@*"/> > <xsl:value-of select=3D"string()"/> > </xsl:element> > </xsl:for-each> This part above will generate the meta-data searchable title. <xsl:apply-templates select=3D"titleproper" mode=3D"sort"/> > </xsl:template> > > <!-- generate sort-title --> > <xsl:template match=3D"titleproper" mode=3D"sort"> > <xsl:variable name=3D"title" select=3D"string(.)"/> > <xsl:if test=3D"number(position()) =3D 1"> > <sort-title> > <xsl:attribute name=3D"xtf:meta" select=3D"'true'"/> > <xsl:attribute name=3D"xtf:tokenize" select=3D"'no'"/> > <xsl:copy-of select=3D"parse:title($title)"/> > </sort-title> > </xsl:if> > </xsl:template> This part above generates the sortable title, with the meta-data field name= d "sort-title". <xsl:template match=3D"titleproper" mode=3D"inmeta"> > <xsl:element name=3D"{name()}"> > <xsl:attribute name=3D"xtf:index" select=3D"'yes'"/> > <xsl:value-of select=3D"string()"/> > </xsl:element> > </xsl:template> > > <xsl:template match=3D"titleproper" mode=3D"inmeta"> > <xsl:element name=3D"{name()}"> > <xsl:attribute name=3D"xtf:meta" select=3D"'true'"/> > <xsl:attribute name=3D"xtf:tokenize" select=3D"'yes'"/> > <xsl:value-of select=3D"string()"/> > </xsl:element> > </xsl:template> This part probably won't do what you want. First of all, I don't think two identical templates are allowed, or if they are, only one of them will run. Since the meta-data one has already been generated, you only need one of these anyway: <xsl:template match=3D"titleproper" mode=3D"inmeta"> <xsl:element name=3D"{name()}"> <xsl:attribute name=3D"xtf:index" select=3D"'yes'"/> <xsl:value-of select=3D"string()"/> </xsl:element> </xsl:template> This will work to output the title element as plain text (that is, no xtf:meta attribute.) The only trouble now is that I don't think the templat= e will be called. So add this to your eadpath template, and it should do the trick: <xsl:apply-templates select=3D"titleproper" mode=3D"inmeta"/> Thanks in advance, and apologies for my mucky xsl. :-P I'll try to pick i= t > up quickly. Hey, don't worry about it. We're all learning here. I'm certainly no xsl wizard myself! Have fun, --Martin |