Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: copying untagged information in an XML2XML transformation

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 10/16/2008 9:04:00 AM
Your XML isn't well-formed so it's hard to test but the reason text isn't 
coming through is that you select elements, with body/*, but not text nodes.
It looks like you should start with the identity template:

<!-- The Identity Transformation -->
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- Whenever you match any node or any attribute -->
  <xsl:template match="node()|@*">
    <!-- Copy the current node -->
    <xsl:copy>
      <!-- Including any attributes it has and any child nodes -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  <!-- Additional templates here -->
</xsl:stylesheet>

then write any additional templates to process nodes as needed. For example 
if you want all text to be bold then add:
<xsl:template match="text()">
  <b><xsl:value-of select="." /></b>
</xsl:template>


-- 

Joe Fawcett (MVP - XML)

http://joe.fawcett.name

"FMAS" <massion@g...> wrote in message 
news:4e635d4d-9f63-4f06-81f5-77375d56539b@t......
>I have been struggling for months to find a way to transform an XML
> file without losing text which is not tagged. Here the simplified XML
> file and XSL file:
>
> XML file:
> ===============
> <?xml version='1.0'?>
> <body>
> </Tu>
> <Tu Origin="manual">
> <Tuv Lang="DE">Definition2 German.</Tuv>
> <Tuv Lang="PL">Definition2 translated.</Tuv>
> </Tu>
> <ut Style="external" DisplayText="SEC2">@Z_SEC2 = </ut>4.2
> <ut Style="external" DisplayText="Ebene 23">@Ebene 23 = </ut>
> <Tu Origin="manual">
> <Tuv Lang="DE">Definition3 German</Tuv>
> <Tuv Lang="PL">Definition3 translated</Tuv>
> </Tu>
> </body>
>
> XSL file:
> ===============
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0" >
> <xsl:template match="/">
> <xsl:for-each select="/body/*">
> <xsl:copy-of select="."/>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> The transformed file has the <Tuv> and the <ut> texts but doesn't
> export text like "4.2" which is important but untagged information.
> Has anyone a clue? 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent