XSLTransformer issue with RichText during import (xml to dxl)

We are importing XML documents into Notes. The import is working except that the RTF (“docBody” in XML & “WebPageBody” in Notes) is missing in the DXL file, which, of course, means that it’s missing in the document. The other fields all import okay.

We are not getting any errors from the tranformer’s.log, the field is missing from the dxl. Since the XML importer is not yet involved, the issue has been determined to be in the translation from XML to DSL. In addition, running the same process in Altova’s XMLSpy tool shows the same behavior. It just skips the template select=docBody line during the step-by-step debug. It also just left RTF out of the resulting DXL. The problem is the template line for docBody.

We have included the pertainent portions of the script code, the xml code, and the xsl code. We are using the domino.dtd from the server.

As we have been unable to find the solution, we would greatly appreciate any assistance from those who have done a RTF export & import with Domino.

Thanks in advance,

Tripp

LS Code Excerpt:

’ set stylesheet stream now. it is same file throughout import …

Set xslStream=s.CreateStream() ’ transforming XSL stream

’ attempt to open xsl/ss stream (transformer’s “style-sheet” - 2nd parameter)

If Not (xslStream.Open(dxlfilepath & xslfilenm)) Then

' unable to open dxl/xml stream, log error, skip to stream close

…

…

End If

’ create stream for importing DXL files to Notes Docs

Set xmlStream=s.CreateStream() ’ source (1st) xml stream

Set dxlStream=s.CreateStream() ’ middle (2nd) dxl stream

’ attempt to open xml stream (transformer’s “input” - 1st parameter)

If Not (xmlStream.Open(xmlinputpath & curfilename)) Then

’ unable to open xml stream, log error

…

…

End If

…

If Not (dxlStream.Open(dxlfilepath & dxlfilename)) Then

' unable to open dxl/xml stream, log error

…

…

End If

’ delete out any current contents (we are not appending)

Call dxlStream.Truncate

’ using transformer, input into current db as new notes

Set xmlImporter = s.CreateDXLImporter(dxlStream, db)

xmlImporter.InputValidationOption = 1 ’ Validate against DTD

’ setup transformer

'Set xmlTransformer=s.CreateXSLTransformer(xmlStream, xslStream, xmlImporter)

Set xmlTransformer=s.CreateXSLTransformer(xmlStream, xslStream, dxlStream)

xmlTransformer.Process

'Call xmlImporter.Process()

…


Code - XSL Stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet xmlns:xsl=“XSLT Namespace” version=“1.0”

xmlns:dxl=“http://www.lotus.com/dxl” exclude-result-prefixes=“dxl”>

<xsl:output method=“xml” indent=“yes” doctype-system=“c:/Lotus/lotusXML/domino.dtd” />

<xsl:template match="/document">

  <document version='1.01' form='WebPage'>

	<xsl:apply-templates  select = "docTitle" />

	<xsl:apply-templates  select = "docBody" />	

</document>

</xsl:template>

<xsl:template match=“docTitle”>

  <text><xsl:value-of select="@Value"/></text>

</xsl:template>

<xsl:template match=“docBody”>

<xsl:copy-of select="."/>

</xsl:template>

<!-- -->

</xsl:stylesheet>


Code - XML Source File

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="http://www.acme.com/aptrix.xsl"?>

<docBody name=“WebPageBody” seal=“false” sign=“false” names=“false” sealed=“false” authors=“false”

readers=“false” placeholder=“false” xmlns=“http://www.lotus.com/dxl”>

<pardef id=“1” list=“none” align=“left” newpage=“false” leftmargin=“1.1250in” spaceafter=“1”

linespacing=“1” rightmargin=“100%” spacebefore=“1” readingorder=“lefttoright”/>

Intro

Line of Body Text

A paragraph of text

describing the wonderful stuff we have and do.

<pardef id=“2” list=“none” align=“left” newpage=“false” leftmargin=“1in” spaceafter=“1”

linespacing=“1” rightmargin=“100%” spacebefore=“1” readingorder=“lefttoright”/>

The second and last

paragraph of text.

Subject: Namespace 2

Hi,what I wanted to say: try to stick to your namespaces. Means: give your input file a namespace so you can reference it in your templates, so you won’t mix the elements. Of course that requires that you generate your elements using

xsl:element

Hth

:slight_smile: stw

Subject: Switching to Namespace Works But Stuck Again

Stephen,

Thanks for your tip. It helped get us most of the way.

We took out the exclude-result-prefixes from the xsl:stylesheet line at the top. Then we added to the source xml file dxl: to give each top tag a namespace. After that the Lotus Transformer and the one in XMLSpy brought back data for the RTF body field. However, we have a formatting issue we have not been able to solve.

We need the dxl:docBody to transform to:

…

By changing the dxl:docBody template to use “*” or “node()”:

<xsl:template match=“dxl:docBody”>

<xsl:copy-of select=“*” />

</xsl:template>

We get this as output:

…

<item=“WebPageBody”>

…

…

The xmlns attribute of richtext is not liked by the XMLImporter. We tried “*”, “.”, “richtext”, “/richtext”, “node()”& “@Value”. We know we have to use copy-of because that’s the only on that follows the structure and returns the tags along with the text within the dxl:docBody tag.

Doing a google search, I found a couple posts that create a temporary variable/parameter and then reference it. Then they show a recursive segment of code with node(). However, we cannot figure out how to connect the call to the variable to have it then do the recursive node():

http://www.biglist.com/lists/xsl-list/archives/200104/msg00829.html

This forum response looks like what we need, but we are missing something to make it all work.

Thanks again.

Subject: RE: Switching to Namespace Works But Stuck Again

instead of use

<xsl:element name=“item”>

<xsl:attribute name=“name”>WebPageBody</xsl:attribute>

<xsl:apply-templates />

</xsl:element>

This will output correctly.

You might need some code to copy 1:1 elements:

<xsl:template match=“*”>

<xsl:variable name=“curTagName” select=“name()”/>

<xsl:element name=“{$curTagName}”>

<xsl:apply-templates select=“@*”/>

xsl:apply-templates/

</xsl:element>

</xsl:template>

<xsl:template match=“@*”>

<xsl:variable name=“curAttName” select=“name()”/>

<xsl:attribute name=“{$curAttName}”><xsl:value-of select=“.”/></xsl:attribute>

</xsl:template>

Subject: RE: Switching to Namespace Works But Stuck Again

I added the 1:1 code and swapped out the item code to get the name. The item and name for the body comes accross perfectly, but the “looping” code is failing. The currently xsl code sniplet:

<xsl:template match="dxl:docBody">

	<xsl:element name="item">

		<xsl:attribute name="name">WebPageBody</xsl:attribute>

		<xsl:apply-templates select="*"/>

	</xsl:element>

</xsl:template>

<!-- templates below allow crawling of tags for RTF file -->

<xsl:template match="*">

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

	<xsl:attribute name="{$curTagName}">

		<xsl:apply-templates select="@*"/>

	</xsl:attribute>

</xsl:template>

<xsl:template match="@*">

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

	<xsl:attribute name="{$curAttName}">

		<xsl:value-of select="."/>

	</xsl:attribute>

</xsl:template>

<!-- -->

The output is simply:

<item name="WebPageBody" richtext=""/>

Subject: Solution

<xsl:template match=“dxl:docBody”> <xsl:element name=“item”>

		<xsl:attribute name="name">WebPageBody</xsl:attribute>

		<xsl:apply-templates />

	</xsl:element>

</xsl:template>

<!-- templates below allow crawling of tags for RTF file -->

<xsl:template match="*">

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

	<xsl:element name="{$curTagName}">

		<xsl:apply-templates select="@*"/>

		<xsl:apply-templates />

	</xsl:element>

</xsl:template>

<xsl:template match="@*">

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

	<xsl:attribute name="{$curAttName}">

		<xsl:value-of select="."/>

	</xsl:attribute>

</xsl:template>

<!-- -->

Thanks Stephan.

Subject: Namespaces might be the issue

Your match looks like <xsl:template match=“docBody”>

try

<xsl:template match=“dxl:docBody”>

worked for us

:wink: stw