Paul Spence
2004-01-19 18:31:53 UTC
Is there any way I can use keys when calling on external XML files using
the document function? I am trying to use the Muenchian grouping
technique to list unique content values for an element, but the values
exist in a document that is external to the one I'm processing.
More detail below (apologies for long post):
I am developing an application that publishes XML files (marked up in
TEI) as static HTML files. I am processing one set of XML files which
create the general web pages themselves, e.g. snippet from 'genweb.xml'
-----------------XML FILE--------------
<TEI.2>
...
<text>
...
<p>This is an index of people:</p>
<divGen id="personIndex" />
<p>And some more text ...</p>
</text>
</TEI.2>
-------------------------------
My TEI publishing process uses the <divGen> element in this XML file to
call for an index to be created at a particular point: in this case, an
index of people.
I have another series of (primary source) XML files that contains
various references to people. Snippet2 from an example 'primary.xml':
-----------------XML FILE--------------
<TEI.2>
...
<text>
...
<p>Some text with mentions of <rs type="person">person 1</rs> and
<rs type="person">person 2</rs>.</p>
<p>And some more text ...</p>
<p>Another mention of <rs type="person">person 1</rs></p>
</text>
</TEI.2>
-------------------------------
I group these primary source files together as a collection in
'master_primary.xml'. I then want to create an index of people mentioned
throughout the collection, with links to the individual mention.
Something like this:
-----------------HTML output--------------
Index of people mentioned
[each asterisk takes you to an individual mention of the person in
question]
person 1: * * *
person 2: * * * * *
-------------------------------
I normally do this with Muenchian grouping, but can't get it working on
external XML files. See following XSLT snippet, which I think crashes
because of the match pattern in <xsl:key>:
-----------------XSLT FILE--------------
<xsl:key name="myKeyName" match="document('master_primary.xml')//rs"
use="normalize-space(.)" />
<xsl:template match="divGen">
<xsl:if test="@id='personIndex'">
<xsl:for-each
select="document('../../xml/02_master/master_object.xml')//rs[generate-i
d(.)=generate-id(key('myKeyName',
normalize-space(.))[1])][@type='person']">
NOW DO SOMETHING ELSE ...
</xsl:for-each>
</xsl:if>
</xsl:template>
---------------------------------------------
I can think of other methods, using intermediate XML output, but would
prefer to avoid them if possible.
I am using Saxon processor version 6.5.2.
Thanks in advance,
Paul
---------------------------------------
Paul Spence
Centre for Computing in the Humanities
King's College London
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
the document function? I am trying to use the Muenchian grouping
technique to list unique content values for an element, but the values
exist in a document that is external to the one I'm processing.
More detail below (apologies for long post):
I am developing an application that publishes XML files (marked up in
TEI) as static HTML files. I am processing one set of XML files which
create the general web pages themselves, e.g. snippet from 'genweb.xml'
-----------------XML FILE--------------
<TEI.2>
...
<text>
...
<p>This is an index of people:</p>
<divGen id="personIndex" />
<p>And some more text ...</p>
</text>
</TEI.2>
-------------------------------
My TEI publishing process uses the <divGen> element in this XML file to
call for an index to be created at a particular point: in this case, an
index of people.
I have another series of (primary source) XML files that contains
various references to people. Snippet2 from an example 'primary.xml':
-----------------XML FILE--------------
<TEI.2>
...
<text>
...
<p>Some text with mentions of <rs type="person">person 1</rs> and
<rs type="person">person 2</rs>.</p>
<p>And some more text ...</p>
<p>Another mention of <rs type="person">person 1</rs></p>
</text>
</TEI.2>
-------------------------------
I group these primary source files together as a collection in
'master_primary.xml'. I then want to create an index of people mentioned
throughout the collection, with links to the individual mention.
Something like this:
-----------------HTML output--------------
Index of people mentioned
[each asterisk takes you to an individual mention of the person in
question]
person 1: * * *
person 2: * * * * *
-------------------------------
I normally do this with Muenchian grouping, but can't get it working on
external XML files. See following XSLT snippet, which I think crashes
because of the match pattern in <xsl:key>:
-----------------XSLT FILE--------------
<xsl:key name="myKeyName" match="document('master_primary.xml')//rs"
use="normalize-space(.)" />
<xsl:template match="divGen">
<xsl:if test="@id='personIndex'">
<xsl:for-each
select="document('../../xml/02_master/master_object.xml')//rs[generate-i
d(.)=generate-id(key('myKeyName',
normalize-space(.))[1])][@type='person']">
NOW DO SOMETHING ELSE ...
</xsl:for-each>
</xsl:if>
</xsl:template>
---------------------------------------------
I can think of other methods, using intermediate XML output, but would
prefer to avoid them if possible.
I am using Saxon processor version 6.5.2.
Thanks in advance,
Paul
---------------------------------------
Paul Spence
Centre for Computing in the Humanities
King's College London
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list