-/* $Id: xslt.c,v 1.11 2005-06-23 06:45:47 adam Exp $
+/* $Id: xslt.c,v 1.12 2005-06-24 13:45:54 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
continue;
if (!strcmp(ptr->name, "index"))
{
- char *name_str = 0;
+ const char *name_str = 0;
const char *type_str = 0;
const char *xpath_str = 0;
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
{
- if (!strcmp(attr->name, "name")
- && attr->children && attr->children->type == XML_TEXT_NODE)
- name_str = attr->children->content;
- if (!strcmp(attr->name, "xpath")
- && attr->children && attr->children->type == XML_TEXT_NODE)
- xpath_str = attr->children->content;
- if (!strcmp(attr->name, "type")
- && attr->children && attr->children->type == XML_TEXT_NODE)
- type_str = attr->children->content;
+ attr_content(attr, "name", &name_str);
+ attr_content(attr, "xpath", &xpath_str);
+ attr_content(attr, "type", &type_str);
}
if (name_str)
{
}
}
+static void index_record(struct filter_info *tinfo,struct recExtractCtrl *ctrl,
+ xmlNodePtr ptr, RecWord *recWord)
+{
+ if (ptr->type == XML_ELEMENT_NODE && ptr->ns &&
+ !strcmp(ptr->ns->href, zebra_xslt_ns)
+ && !strcmp(ptr->name, "record"))
+ {
+ const char *type_str = "update";
+ const char *id_str = 0;
+ struct _xmlAttr *attr;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ attr_content(attr, "type", &type_str);
+ attr_content(attr, "id", &id_str);
+ }
+ if (id_str)
+ sscanf(id_str, "%255s", ctrl->match_criteria);
+
+ ptr = ptr->children;
+ }
+ index_node(tinfo, ctrl, ptr, recWord);
+}
+
static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p,
xmlDocPtr doc)
{
fwrite(buf_out, len_out, 1, stdout);
xmlFree(buf_out);
}
- index_node(tinfo, p, xmlDocGetRootElement(resDoc), &recWord);
+ index_record(tinfo, p, xmlDocGetRootElement(resDoc), &recWord);
xmlFreeDoc(resDoc);
}
xmlDocDumpMemory(doc, &buf_out, &len_out);
if (p->score >= 0)
set_param_int(params, "score", p->score, p->odr);
set_param_int(params, "size", p->recordSize, p->odr);
-
+ set_param_int(params, "id", p->localno, p->odr);
+
if (window_size >= 0)
set_param_xml(params, "snippet", snippet_doc(p, 1, window_size),
p->odr);
xmlns:m="http://www.loc.gov/MARC21/slim"
xmlns:z="http://indexdata.dk/zebra/xslt/1"
version="1.0">
- <!-- $Id: index.xsl,v 1.3 2005-06-15 15:30:05 adam Exp $ -->
+ <!-- $Id: index.xsl,v 1.4 2005-06-24 13:45:54 adam Exp $ -->
<xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
- <xsl:template match="/m:record/m:controlfield[@tag=001]">
+
+ <xsl:template match="text()"/>
+
+
+ <xsl:template match="/m:record">
+ <z:record id="{normalize-space(m:controlfield[@tag='001'])}">
+ <xsl:apply-templates/>
+ </z:record>
+ </xsl:template>
+
+ <xsl:template match="m:controlfield[@tag='001']">
<z:index name="control">
- <xsl:apply-templates match="."/>
+ <xsl:value-of select="."/>
</z:index>
</xsl:template>
- <xsl:template match="/m:record/m:datafield[@tag=245]">
+ <xsl:template match="m:datafield[@tag='245']/m:subfield[@code='a']">
<z:index name="title">
- <xsl:apply-templates match="."/>
+ <xsl:value-of select="."/>
</z:index>
</xsl:template>
+
+
</xsl:stylesheet>