Dynamic xi:include/xpointer resolution
Posted: Thu Dec 11, 2008 6:36 am
Hey everybody,
if this is not an XSLT but an XInclude question, I apologize in advance.
I'm working on book-type documents and I'm trying to pull in bibliographic information/document fragments of works mentioned/cited in ptr elements' @target attributes in a text document (1. content.xml) from a bibliography master file (2. master-biblio.xml) with an XSL transform (3. transform.xsl) in order to achieve something like 4. desired-output.xml. (N.B.: I am aware that I should use a unique list based on keys for that purpose; the following code samples are simplified.)
Specifically, I seem to have problems (Saxon 6.5.5: "InvalidShortHandPointer: The NCName of the ShortHand Pointer '{$currentID}' is invalid.") with evaluating what I want to pass to the xpointer attribute as a value.
Please ignore tei:teiHeader elements below. My problem seems to occur at the line in "3. XSL transform" below.
Any comments are highly appreciated!
1. Source document (content.xml):
2. Master bibliography file to be referenced/processed for fragment inclusion (master-biblio.xml):
3. XSL transform (transform.xsl):
4. Desired output (desired-output.xml):
Markus Flatscher
Editor
The Collected Works of Ferdinand Ebner (Austrian Science Fund Project #P18428)
markus.flatscher@gmail.com
http://www.ebner-gesellschaft.org
if this is not an XSLT but an XInclude question, I apologize in advance.
I'm working on book-type documents and I'm trying to pull in bibliographic information/document fragments of works mentioned/cited in ptr elements' @target attributes in a text document (1. content.xml) from a bibliography master file (2. master-biblio.xml) with an XSL transform (3. transform.xsl) in order to achieve something like 4. desired-output.xml. (N.B.: I am aware that I should use a unique list based on keys for that purpose; the following code samples are simplified.)
Specifically, I seem to have problems (Saxon 6.5.5: "InvalidShortHandPointer: The NCName of the ShortHand Pointer '{$currentID}' is invalid.") with evaluating what I want to pass to the xpointer attribute as a value.
Please ignore tei:teiHeader elements below. My problem seems to occur at the line
Code: Select all
<xi:include href="master-biblio.xml" xpointer="{$currentID}"/>
Any comments are highly appreciated!
1. Source document (content.xml):
Code: Select all
<?oxygen RNGSchema="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/teilite.rng" type="xml"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Title</title>
</titleStmt>
<publicationStmt>
<p>Publication information</p>
</publicationStmt>
<sourceDesc>
<p>Information about the source</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<p>We cite this (<ptr target="#this"/>) and that (<ptr target="#that"/>).</p>
</body>
</text>
</TEI>
Code: Select all
<?oxygen RNGSchema="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/teilite.rng" type="xml"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Title</title>
</titleStmt>
<publicationStmt>
<p>Publication information</p>
</publicationStmt>
<sourceDesc>
<p>Information about the source</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<listBibl>
<bibl xml:id="this">This name: this title, blah</bibl>
<bibl xml:id="that">That name: that title, bleh</bibl>
</listBibl>
</body>
</text>
</TEI>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude">
<xsl:template match="/">
<xsl:element name="list">
<xsl:for-each select="//tei:ptr">
<xsl:sort select="@target"/>
<xsl:element name="item">
<xsl:variable name="currentID" select="substring-after('@target','#')"/>
<xi:include href="master-biblio.xml" xpointer="{$currentID}"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<list>
<item>
<bibl xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude"
xml:id="that" xml:base="master-biblio.xml">That name: that title, bleh</bibl>
</item>
<item>
<bibl xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude"
xml:id="this" xml:base="master-biblio.xml">This name: this title, bleh</bibl>
</item>
</list>
Markus Flatscher
Editor
The Collected Works of Ferdinand Ebner (Austrian Science Fund Project #P18428)
markus.flatscher@gmail.com
http://www.ebner-gesellschaft.org