[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Problem with doctype-system in transformation xml to xml


Subject: Re: [xsl] Problem with doctype-system in transformation xml to xml
From: "Axel Kesten" <kesten@xxxxxxxxxxxxxxx>
Date: Wed, 7 Dec 2005 13:59:15 +0100

Hi Andrew

below i've inserted the stylesheet.

Maybe, it's not very efficient, but I'm not so experienced in XSL.

Because of the structure of the xml-files i'm evaluating, the </A> is
written to the output tree after the <A>.

The stylesheet is not so long. I have copied it completely into the posting,
because i didn't know what to delete.

Kind regards

Axel
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
omit-xml-declaration="no" doctype-system="C:\A.dtd" media-type="text/xml" />



<xsl:template match="/">

<xsl:variable name="knotenname" select="A/CATEGORY"></xsl:variable>

<xsl:choose>

<xsl:when test="$nodename='test'">

<!-- node from the called files, defined in the config-file-->

<xsl:call-template name="Copy"></xsl:call-template>

</xsl:when>

<xsl:otherwise>

</xsl:otherwise>

</xsl:choose>

<xsl:for-each select="/C/D/E">

<!-- nodes from the config-file -->

<xsl:variable name="first" select="position()"></xsl:variable>

<xsl:choose>

<xsl:when test="$first=1">

<xsl:call-template name="head"></xsl:call-template>

</xsl:when>

</xsl:choose>

<xsl:variable name="doc_name" select="."></xsl:variable>

<xsl:apply-templates select="document($doc_name)"></xsl:apply-templates>

<!-- opening a file form the list in the config-file -->

<xsl:if test="$first=last()">

<xsl:text disable-output-escaping="yes">&lt;/A&gt;</xsl:text>

</xsl:if>

</xsl:for-each>

</xsl:template>


<xsl:template name="head">

<xsl:text disable-output-escaping="yes">&lt;A&gt;</xsl:text>

</xsl:template>



<xsl:template name="Copy">

<xsl:copy-of select="A/F/G/H/*"></xsl:copy-of>

<!-- other nodes in the opened file -->

</xsl:template>

</xsl:stylesheet>


----- Original Message -----
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>

On 12/7/05, Axel Kesten <kesten@xxxxxxxxxxxxxxx> wrote:

For this to happen <B> must be the root element of your output, eg:

<xsl:template match="/">
  <B>
    ...

You need to post a small complete example stylesheet that causes this
problem so it can be recreated, eg


Current Thread