Hello All
I am trying to convert a Framemaker XML Document to an XML Document that
conforms to our custom DTD. The Frame XML looks something like this:
<XML>
<TITLE/>
<Heading-1>
<A ID="pgfId-1009125"/> CASINGS</Heading-1>
<Body>
<A ID="pgfId-1009975"/> Designer's responsibility</Body>
<Alpha-FirstList>
<Alpha-First>
<A ID="pgfId-1009976"/> vertical is required.</Alpha-First>
<Alpha-Next>
<A ID="pgfId-1009987"/> stress.</Alpha-Next>
<Alpha-Next>
<A ID="pgfId-1009988"/> Sufficient to avoid such
problems</Alpha-Next>
</Alpha-FirstList>
<Heading-2>
<A ID="pgfId-1012502"/> Applicable Documents</Heading-2>
<Body>
<A ID="pgfId-1012503"/> The following publications form a part of
this document to the extent specified herein</Body>
<Heading-1>
<A ID="pgfId-1010000"/> NOTE</Heading-1>
<Body>
<A ID="pgfId-1010001"/> The | symbol is used to indicate technical
and major editorial changes</Body>
</XML>
It to be something like this:
<engineering.doc>
<dm>
<dm.frontmatter><!---some elements here--></dm.frontmatter>
<body>
<section>
<heading id="pgfId-1009125">CASINGS</heading>
<para>Designer's responsibility</para>
<!---list in here--->
<section>
<heading id="pgfId-1012502">Applicable Documents</heading>
<para>The following publications form a part of this document
to the extent specified herein</para>
</section>
</section>
<section>
<heading id="pgfId-1010000">NOTE</heading>
<para>The | symbol is used to indicate technical and major
editorial changes</para>
</section></body></engineering.doc>
My Stylesheet, thus far looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output doctype-system="EngineeringDoc.dtd" encoding="UTF-8"
indent="yes" method="xml"
version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="XML">
<engineering.doc trans.canada.note="no" status="draft"
export.control="no" qmsp.additional.requirements="no">
<dm>
<dm.frontmatter><!--some elements--></dm.frontmatter>
<body>
<xsl:for-each-group select="*"
group-starting-with="Heading-1">
<section>
<xsl:for-each select="current-group()">
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:for-each-group select="*"
group-starting-with="Heading-2">
<section>
<xsl:for-each select="current-group()">
<xsl:apply-templates
select="."></xsl:apply-templates>
</xsl:for-each>
<xsl:for-each-group select="*"
group-starting-with="Heading-3">
<section>
<xsl:for-each
select="current-group()">
<xsl:apply-templates
select="."></xsl:apply-templates>
</xsl:for-each>
</section>
</xsl:for-each-group>
</section>
</xsl:for-each-group>
</section>
</xsl:for-each-group>
</body>
</dm>
</engineering.doc>
</xsl:template>
<xsl:template match="Body | Normal">
<para>
<xsl:apply-templates/>
</para>
</xsl:template>
<xsl:template match="Heading-1| Heading-2 | Heading-3 | Heading-4 |
Heading-5">
<heading>
<xsl:if test="A">
<xsl:attribute name="id">
<xsl:value-of select="A[1]/@ID"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates />
</heading>
</xsl:template>
</xsl:stylesheet>
This is the result I get using Saxon 8B:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE engineering.doc
SYSTEM "EngineeringDoc.dtd">
<engineering.doc trans.canada.note="no" status="draft" export.control="no"
qmsp.additional.requirements="no">
<dm>
<dm.frontmatter><!--some elements--></dm.frontmatter>
<body>
<section/>
<section>
<heading id="pgfId-1009125"> CASINGS</heading>
<para> Designer's responsibility</para> <!--list stuff-->
<heading id="pgfId-1012502"> Applicable Documents</heading>
<para> The following publications form a part of this document
to the
extent specified herein</para>
<section/>
</section>
<section>
<heading id="pgfId-1010000"> NOTE</heading>
<para> The | symbol is used to indicate technical and major
editorial
changes </para>
<section/>
</section>
</body>
</dm>
</engineering.doc>
Does anyone know how I can get the desired result?
TIA
Nadia
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--