Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: copying untagged information in an XML2XML transformation [Thread Next] Re: copying untagged information in an XML2XML transformationTo: NULL Date: 11/1/2008 8:03:00 AM On 16 Okt., 09:04, "Joe Fawcett" <joefawc...@newsgroup.nospam> wrote: > 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 nod= es. > It looks like you should start with the identity template: > > <!-- The Identity Transformation --> > <xsl:stylesheet version=3D"1.0" > xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"> > =A0 <!-- Whenever you match any node or any attribute --> > =A0 <xsl:template match=3D"node()|@*"> > =A0 =A0 <!-- Copy the current node --> > =A0 =A0 <xsl:copy> > =A0 =A0 =A0 <!-- Including any attributes it has and any child nodes --> > =A0 =A0 =A0 <xsl:apply-templates select=3D"@*|node()"/> > =A0 =A0 </xsl:copy> > =A0 </xsl:template> > =A0 <!-- Additional templates here --> > </xsl:stylesheet> > > then write any additional templates to process nodes as needed. For examp= le > if you want all text to be bold then add: > <xsl:template match=3D"text()"> > =A0 <b><xsl:value-of select=3D"." /></b> > </xsl:template> > > -- > > Joe Fawcett (MVP - XML) > > http://joe.fawcett.name > > "FMAS" <mass...@gmx.de> 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: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > <?xml version=3D'1.0'?> > > <body> > > </Tu> > > <Tu Origin=3D"manual"> > > <Tuv Lang=3D"DE">Definition2 German.</Tuv> > > <Tuv Lang=3D"PL">Definition2 translated.</Tuv> > > </Tu> > > <ut Style=3D"external" DisplayText=3D"SEC2">@Z_SEC2 =3D </ut>4.2 > > <ut Style=3D"external" DisplayText=3D"Ebene 23">@Ebene 23 =3D </ut> > > <Tu Origin=3D"manual"> > > <Tuv Lang=3D"DE">Definition3 German</Tuv> > > <Tuv Lang=3D"PL">Definition3 translated</Tuv> > > </Tu> > > </body> > > > XSL file: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > <?xml version=3D"1.0"?> > > <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" > > version=3D"1.0" > > > <xsl:template match=3D"/"> > > <xsl:for-each select=3D"/body/*"> > > <xsl:copy-of select=3D"."/> > > </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?- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - I have now found the solution. The issue was basically that I had a node followed either by normal tags or by plain text. With my transformation I had only be capable of transforming the tagged content and I was losing the text. Now I check (with choose/when/ otherwise) if the content following the tagged content is text only. I do this with the following line: <xsl:otherwise> <xsl:value-of select=3D"normalize-space(following-sibling::node()[1] [self::text()])"/> </xsl:otherwise> This works. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
