Sometimes, you know that there is content inside the main XML document that you would like to use for another purpose. The most common alternative purpose is something like making a list of figures or a table of contents from captions and titles in the XML file. But you can be more creative. Perhaps you need to find all of the keywords that were tagged in an XML file and extract them to build the foundations for a glossary XML file. Here is some XML content with keywords:
glossaryTest.xml
<Story name="Residency Requirements">
<SectionHead>Residency Requirements</SectionHead>
<para>New York State law requires that all students
file proof of residence each academic year. For New York State residents
, the proper form should be submitted upon registration. Until you comply
with this requirement, you will be billed the <keyword>
non-resident tuition rate</keyword> (twice the resident rate).</para>
<topic title="Residents of Monroe County">
<SubHeads>Residents of Monroe County</SubHeads>
<para>If you have been a permanent legal resident of
New York State for the past year, and a resident of Monroe County for
the last six months, complete a Residency Certificate/<keyword>
Affidavit</keyword>, sign it, and submit it with your registration.</para>
</topic> [more...]
</Story>An XSL transform can be pretty simple:
makeGlossary.xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<!-- make a new root element for the glossary XML -->
<xsl:element name="glossary">
<xsl:for-each select="//keyword">
<!-- make an element for the term -->
<xsl:element name="term">Term: <xsl:value-of
select="."/></xsl:element>
<!-- make an element for the definition -->
<xsl:element name="definition">Definition: </xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>The results will be very useful: a new glossary XML file, with keywords as terms, and a blank definition element following each term, ready for an author to work on. Because the keywords were in the source XML, and they are all now terms in the output XML, the transform makes it easy to correlate the glossary to the document that contains the keywords.
glossaryOutput_XSL.xml
<?xml version="1.0" encoding="UTF-8"?>
<glossary>
<term>Term: non-resident tuition rate</term>
<definition>Definition: </definition>
<term>Term: Affidavit</term>
<definition>Definition: </definition>
</glossary>This type of XSL seems to work well on an existing InDesign file tagged with keywords. On export, if the XSL is used, the resulting file will just be the glossary XML, which you can put in a document of its own or into sidebars in a separate text flow in the same document as the original XML.
Alternately, you could export the entire document XML, and then apply the transform to the exported XML (using an XSLT processor such as Oxygen or XML Spy) to get your starting glossary XML file.
Learn more about this topic from XML Publishing with Adobe InDesign.
From Adobe InDesign CS2 to InDesign CS5, the ability to work with XML content has been built into every version of InDesign. Some of the useful applications are importing database content into InDesign to create catalog pages, exporting XML that will be useful for subsequent publishing processes, and building chunks of content that can be reused in multiple publications.
In this Short Cut, we’ll play with the contents of a college course catalog and see how we can use XML for course descriptions, tables, and other content. Underlying principles of XML structure, DTDs, and the InDesign namespace will help you develop your own XML processes. We’ll touch briefly on using InDesign to “skin” XML content, exporting as XHTML, InCopy, and the IDML package. The Advanced Topics section gives tips on using XSLT to manipulate XML in conjunction with InDesign.

Help


