[xsl] Merging dita files

Subject: [xsl] Merging dita files
From: "Shailesh Shinde" <shailesh@xxxxxxxxxxxx>
Date: Tue, 5 Sep 2006 17:01:47 +0530
Hi All,

I have to merge .dita file into one output.dita using xslt 2.0.

For the same I have "tecra.ditamap" which consists of attribute href which
have reference the files to be merge in the same sequence....


<topicref collection-type="family" type="chapter">
  <topicref href="2_introduction.dita" type="topic"/>
  <topicref href="3_the-grand-tour.dita" type="topic"/>
  <topicref href="4_getting-started.dita" type="topic"/>
  <topicref href="5_operating-basics.dita" type="topic"/>
  <topicref href="6_keyboard.dita" type="topic"/>
  <topicref href="7_power-and-power-up-modes.dita" type="topic"/>
  <topicref href="8_hw-setup.dita" type="topic"/>
  <topicref href="9_optional-devices.dita" type="topic"/>
  <topicref href="10_troubleshooting.dita" type="topic"/>
  <topicref href="11_disclaimers.dita" type="topic"/>
</topicref>

<topicref collection-type="family" type="appendix">
  <topicref href="12_appendix-A.dita" type="topic"/>
  <topicref href="13_appendix-B.dita" type="topic"/>
  <topicref href="14_appendix-C.dita" type="topic"/>
  <topicref href="15_appendix-D.dita" type="topic"/>
  <topicref href="16_appendix-E.dita" type="topic"/>
  <topicref href="17_appendix-F.dita" type="topic"/>
  <topicref href="18_appendix-G.dita" type="topic"/>
  <topicref href="19_appendix-H.dita" type="topic"/>
  <topicref href="20_appendix-I.dita" type="topic"/>
</topicref>


For the same I have done something like this........

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:saxon="http://icl.com/saxon"; extension-element-prefixes="saxon">
	<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
	<xsl:output method="xml" indent="yes" name="xml"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="/">
			<book>
			<xsl:for-each
select="map/topicref[not(@type='glossary')]">
							<xsl:value-of
select="concat(substring-before(substring-after(@href,'/dita/'),'.'),'')"/>
					<xsl:apply-templates
select="document(@href)/dita"/>
					<xsl:apply-templates/>
		</xsl:for-each>

		<xsl:for-each
select="map/topicref[(@type='chapter')]/topicref">
					<xsl:value-of
select="concat(substring-before(substring-after(@href,'/dita/'),'.'),'')"/>
					<xsl:apply-templates
select="document(@href)/dita"/>
					<xsl:apply-templates/>
		</xsl:for-each>
		
		<xsl:for-each
select="map/topicref[(@type='appendix')]/topicref">
					<xsl:value-of
select="concat(substring-before(substring-after(@href,'/dita/'),'.'),'')"/>
					<xsl:apply-templates
select="document(@href)/dita"/>
					<xsl:apply-templates/>
		</xsl:for-each>
		
		<xsl:for-each select="map/topicref[(@type='glossary')]">
							<xsl:value-of
select="concat(substring-before(substring-after(@href,'/dita/'),'.'),'')"/>
					<xsl:apply-templates
select="document(@href)/dita"/>
					<xsl:apply-templates/>
		</xsl:for-each>
		
				<xsl:for-each
select="map/topicref[(@type='Index')]">
							<xsl:value-of
select="concat(substring-before(substring-after(@href,'/dita/'),'.'),'')"/>
					<xsl:apply-templates
select="document(@href)/dita"/>
					<xsl:apply-templates/>
		</xsl:for-each>
		
		</book>
	</xsl:template>

	<xsl:template match="dita">
		<xsl:copy-of select="."/>
	</xsl:template>
</xsl:stylesheet>


But I am not getting output for appendix as <dita type="appendix"> instead
of this I am getting <dita type="chapter">

Can you please tell me where it goes wrong.

Thanks,
Shailesh

Current Thread