I am hoping someone can send me to a good tutorial or working model.
I am a rank neophyte trying working on a project that will present multiple witnesses to strongly aligned texts, each in a separate xml (TEI) file and each <ab> has a unique xml:id. The alignment is to a central xml file, which links out to the unique IDs.
For demo purposes, I'd like to be able to use XSLT to pull the corresponding texts from the several files into a single html file. Any advice on how best to get started?
Getting started with XSLT document() ?
(6 posts) (3 voices)-
Posted 4 years ago Permalink
-
So I'm a little confused here. Are you combining a lot of files into one file with XSLT, or turning one file into a lot of files? Or both?
Posted 4 years ago Permalink -
Thanks for the reply, and sorry to be unclear.
I am trying to extract text from a bunch of xml docs, and bundle them into a single html output.Posted 4 years ago Permalink -
If you're needing to combine multiple documents flexibly, then you probably want to do it in a scripting language rather than in pure XSL. If you know in advance the names of the files you wish to combine, you could do something like this:
First, the XML document that lists the child documents to combine. This assumes that the list is static and that you know the filenames in advance (not through user-submitted parameters, for instance).
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="combine.xsl"?> <documents> <document href="temp1.xml"/> <document href="temp2.xml"/> </documents>
Next we have the XSL document that we could name
combine.xsl
. When processed from the file above, it should go through each document and pull in the actual contents, wrapped in a new root tag.<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"> <!-- match root documents tag --> <xsl:template match="/"> <!-- wrap documents in a new root tag --> <combined-documents> <xsl:apply-templates select="document(/documents/document/@href)" mode="document"/> </combined-documents> </xsl:template> <!-- this will match the root tag of each document --> <xsl:template match="/" mode="document"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet>
Posted 4 years ago Permalink -
I should have mentioned, BTW, that the code above was adapted from http://www.biglist.com/lists/xsl-list/archives/200108/msg00545.html
Posted 4 years ago Permalink -
Thank you so much! This is a great step jump forward for me.
Posted 4 years ago Permalink
Reply
You must log in to post.