1 | <?xml version="1.0" encoding="UTF-8" ?>
|
---|
2 | <!-- This file is part of the DITA Open Toolkit project hosted on
|
---|
3 | Sourceforge.net. See the accompanying license.txt file for
|
---|
4 | applicable licenses.-->
|
---|
5 | <!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
|
---|
6 |
|
---|
7 | <!-- specialize.xsl
|
---|
8 | | Convert "generalized" DITA topics back into specialized form
|
---|
9 | *-->
|
---|
10 |
|
---|
11 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
12 | <xsl:output method="xml" indent="no"/>
|
---|
13 | <!--Find the class attribute within the XML instance document. -->
|
---|
14 | <xsl:template match="*[@class]">
|
---|
15 | <xsl:call-template name="specialize">
|
---|
16 | <xsl:with-param name="class" select="@class"/>
|
---|
17 | </xsl:call-template>
|
---|
18 | </xsl:template>
|
---|
19 | <!--Look for the last class definition, i.e, task/steps. Replace existing generalized element name
|
---|
20 | with specialized element name -->
|
---|
21 | <xsl:template name="specialize">
|
---|
22 | <xsl:param name="class"/>
|
---|
23 | <xsl:choose>
|
---|
24 | <xsl:when test="contains(normalize-space($class),' ')">
|
---|
25 | <xsl:call-template name="specialize">
|
---|
26 | <xsl:with-param name="class" select="substring-after($class,' ')"/>
|
---|
27 | </xsl:call-template>
|
---|
28 | </xsl:when>
|
---|
29 | <xsl:otherwise>
|
---|
30 | <xsl:variable name="element_name" select="substring-after(normalize-space($class),'/')" />
|
---|
31 | <xsl:element name="{$element_name}">
|
---|
32 | <xsl:copy-of select="@*[local-name() != 'class']"/>
|
---|
33 | <xsl:apply-templates/>
|
---|
34 | </xsl:element>
|
---|
35 | </xsl:otherwise>
|
---|
36 | </xsl:choose>
|
---|
37 | </xsl:template>
|
---|
38 | <!--pick up everything from the element -->
|
---|
39 | <xsl:template match="*|@*|comment()|processing-instruction()|text()">
|
---|
40 | <xsl:copy>
|
---|
41 | <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
|
---|
42 | </xsl:copy>
|
---|
43 | </xsl:template>
|
---|
44 |
|
---|
45 | <xsl:template match="*[contains(@class,' topic/object ')][@data and not(@data='')][@type='DITA-foreign']" priority="10">
|
---|
46 | <xsl:apply-templates select="document(@data,/)/*/*" mode="specialize-foreign-unknown"/>
|
---|
47 | </xsl:template>
|
---|
48 |
|
---|
49 | <xsl:template match="*|@*|text()|comment()|processing-instruction()" mode="specialize-foreign-unknown">
|
---|
50 | <xsl:copy>
|
---|
51 | <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()" mode="specialize-foreign-unknown"/>
|
---|
52 | </xsl:copy>
|
---|
53 | </xsl:template>
|
---|
54 |
|
---|
55 | </xsl:stylesheet>
|
---|
56 |
|
---|