XSL transform operation failed

I’m trying to use CreateXSLTransformer to run a transformation on an XML file and then import it as records into a database. I keep getting the error message “XSL transform operation as failed” (on the marked line below). I’ve run the transform using XMLSpy and at a command line using the Saxon parser - there are no errors and the transform works correctly. So it has to be something on the Lotus side, but I don’t know what. Any ideas?

Sub Initialize

On Error Goto errhand

Dim s As New notessession

Dim InputStream As NotesStream

Dim StyleStream As NotesStream

Dim transformer As NotesXSLTransformer

Dim Importer As NotesDXLImporter

Dim db As Notesdatabase

Dim doc As notesdocument

Dim xmlFile As String

Dim xslFile As String

Dim filePath As String



Set db = s.currentdatabase



xmlFile = "ddiscpub_sfa_20051121_013400_4.xml"

xslFile = "tranformCustData.xsl"

filePath = "c:\dxl\"

Set InputStream = s.CreateStream

If Not InputStream.Open(filepath & xmlFile) Then

	Msgbox "Cannot open " & filePath & xmlFile

	Exit Sub

End If



Set StyleStream = s.CreateStream

If Not StyleStream.Open(filepath & xslFile) Then

	Msgbox "cannot open " & filePath & xslFile

	Exit Sub

End If



Set transformer = s.CreateXSLTransformer(InputStream, StyleStream)

Set Importer = s.CreateDXLImporter(transformer, db)

transformer.process 'errors on this line

InputStream.Close

StyleStream.Close



Exit Sub

errhand:

Msgbox "error at line " & Erl & ": " & Error

Exit Sub

End Sub

Subject: XSL transform operation failed

Hi Esther,

I think you have to add the following…

Call transformer.Process

Call InputStream.Close

Call StyleStream.Close

Let me know if this is the solution to your problem.

James Greene

Jagre Incorporated

www.jagre.net

Subject: RE: XSL transform operation failed

Uh, those are the last three lines of the code I posted (before the error-trapping). So I’m guessing it’s not the solution…

Subject: RE: XSL transform operation failed

Esther,

When I read your post, I looked at the sample code in the Designer Help and noticed your code did not “Call” the methods. This is why I wrote my response.

Your code is:

transformer.process 'errors on this line

InputStream.Close

StyleStream.Close

My code is:

Call transformer.process

Call InputStream.Close

Call StyleStream.Close

I am not certain if this will help you with your problem, but it is what the help presents as proper usage.

I continue to be interested in learning how you solve the problem or work around the problem.

Regards,

James Greene

Jagre Incorporated

www.jagre.net

Subject: RE: XSL transform operation failed

Sorry, I missed the Call part. I’ll try it and see. But the sample code for NotesXSLTransformer doesn’t use Call, although CreateXSLTransformer does. Strange.

Subject: RE: XSL transform operation failed

Nope, that didn’t do it. Thanks anyway - I know sometimes things like that do make a difference.

Subject: RE: XSL transform operation failed

I’ve found that the Log propertyis a big help when dealing with the XML stuff. It should give you an XML document pointing to the problem. You may have to examine either the XML or XSLT in a text editor to translate the log line number error to something more concrete, but it’s more help than guessing.

Subject: RE: XSL transform operation failed

I’ll take a look at that for future reference, but did eventually get things to work, albeit with an extra step. I write the transform to an external text file, then immediately turn around and reuse that stream to pass to the DXLImporter. I would have preferred to skip the text file and go straight to the importer, but it at least works now - I can waste time figuring out why the prettier solution didn’t work when I have more time.

Subject: RE: XSL transform operation failed

OK, Stan. Out of curiousity I tried the Log property, and did get an error, but I’m not sure what it means. Any ideas?

The stylesheet is the same one that works if I send the tranform to an external file first, and then import the results. The code in all of the XML/XSL files is extremely simple, so I’m not sure where it’s thinking the document is empty.

This is the input XML:

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

<ns0:DisciplineUpdate Count=“22” DisciplineUpdateDateTime=“2005-11-21T01:34:00” FileName=“short_sfa.xml” xmlns:ns0=“HMH: K-12 Adaptive Learning Company | HMH”>

<ns0:Discipline CorporateLevel2Subject=“01” CorporateLevel2SubjectDescription=“02”>

<ns0:DivisionalData AssigningDivision="01" AssigningDivisionDescription="Product Division 01" DisciplineType="GGG" />

</ns0:Discipline>

</ns0:DisciplineUpdate>

And the stylesheet:

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

<xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace” :ns0=“HMH: K-12 Adaptive Learning Company | HMH”>

<xsl:output method=“xml” indent=“yes” />

<xsl:template match=“/”>

xsl:apply-templates/

</xsl:template>

<xsl:template match=“ns0:DisciplineUpdate”>

xsl:apply:templates/

</xsl:template>

<xsl:template match=“ns0:Discipline”>

<document form='Doc'>

	<item name='CorporateLevel2Subject'><text><xsl:value-of select="@CorporateLevel2Subject"/></text></item>

	<item name='CorporateLevel2SubjectDescription'><text><xsl:value-of select="@CorporateLevel2SubjectDescription"/></text></item>

	<xsl:apply-templates/>		

</document>

</xsl:template>

<xsl:template match=“ns0:DivisionalData”>

<item name='AssigningDivision'><text><xsl:value-of select="@AssigningDivision"/></text></item>

<item name='AssigningDivisionDescription'><text><xsl:value-of select="@AssigningDivisionDescription"/></text></item>

<item name='DisciplineType'><text><xsl:value-of select="@DisciplineType"/></text></item>

</xsl:template>

<xsl:template match=“text()” />

</xsl:stylesheet>

Subject: RE: XSL transform operation failed

Yes. It means that at the moment of processing, the data from your XSLT isn’t available in the stream. The error log is indicating that it can’t find the root document element for the stylesheet, so either the stream is empty or the root document tag (xsl:stylesheet) is unclosed. Can you try reading the stream as a string to see what’s there?

Subject: RE: XSL transform operation failed

Thanks for all the suggestions. I’ll keep them in mind for next time I run into a real problem… alas, this was just stupidity. I had a typo in the name of my XSL file, so it wasn’t finding it.

Subject: RE: XSL transform operation failed

Well, I tried. Good luck.