 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 24th, 2008, 05:59 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Operation is not allowed when obejct is closed
Hope this finds you good , attached here with a function which i call inside in a xslt for each loop to update a DB , but unfortunately it is claiming that the operation is not allowed when the object is closed
Can you give me a hand in this , appreciate your quick response
here is the vbfunction
Function UpdateCOA(AccDimCode,Name,manager,closed,category, Rep1,Rep2,Rep3,Rep4,Rep5,RepLevel,AllocNum,AutoAcc ,AccrualAcc,AccrualYear,AccrualPer,UsrGrp,cc,db)
'Function to get EAN code from Stock Item and replace that stock code with the EAN
' Function to get EAN code from Stock Item and replace that stock code with the EAN
dsn = "Provider=SQLOLEDB;Trusted_Connection=yes; Data Source="+db+"; Initial Catalog=ScaSystemDB;" +_
" user id='user'; password='pwd'"
set cn= createObject("ADODB.connection")
cn.open dsn
sqlStmt = "select DBName from ScaCompanies where CompanyCode = '"&cc&"'"
Set recData = CreateObject("ADODB.Recordset")
recData.open sqlStmt,cn
if not recData.EOF then databaseName = recData(0)
recData.close
cn.close
dsn = "Provider=SQLOLEDB;Trusted_Connection=yes; Data Source="+db+"; Initial Catalog=" +_
databaseName+"; user id='user'; password='pwd'"
set cn=createObject("ADODB.connection")
cn.open dsn
' Check for OVT code
accountexists = 0
Set recData = CreateObject("ADODB.Recordset")
sqlStmt = "Update GL03"+cc+"06 Set GL03003 = '"+ Name +"' , GL03006 = '"+ manager +"' , GL03007 = '" + closed + "', GL03008 = '" + category +_
"', GL03009 = '" + Rep1 + "' , GL03010 = '" + Rep2 + "', GL03011 = '" + Rep3 + "', GL03012 = '" + Rep4 + "', GL03013 = '" + Rep5 +_
"' , GL03014 = '" + RepLevel + "', GL03015 = '" + AllocNum + "' , GL03016 = '" + AutoCc +_
" ', GL03017 = '"+ AccrualAcc +"', GL03018 = '" + AccrualYear+ "', GL03019 = '"+ AccrualPer + "',GL03020 = '" + UsrGrp + "' WHERE GL03001 = '" + AccDimCode + "'"
recData.open sqlStmt,cn
if not recData.EOF then
if Len(recData(0)) > 0 then
TmpSupplier = recData(0)
else
TmpSupplier = supplier
end if
end if
recData.Close
cn.close
UpdateCOA = sqlStmt
End Function
|
|

July 24th, 2008, 06:12 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Hi
How is this error related to XSLT exactly?
Have you tried doing the most simple of google searches for your error message? (I can tell you haven't)
/- Sam Judson : Wrox Technical Editor -/
|
|

July 24th, 2008, 06:15 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes i have tried google it , first i don't know if it is related to xslt or not but i don't see any error in the vb code so i thought that the problem with the for-each loop inside the xslt , really i don't know , that why i need your help here.
appreciate your effort and quick response
|
|

July 24th, 2008, 06:23 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
If you don't know where your error is coming then we can't really help you. Also you didn't actually show any XSLT, so if there is an error in your XSLT how would we know?
Have you tried putting your vbscript into a separate file and testing it independently as I think you'll find the error message you are reporting is an ADO error.
/- Sam Judson : Wrox Technical Editor -/
|
|

July 24th, 2008, 06:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Surely there's some indication, how are you running this in XSLT (and why...)? Does the code work as a standalone app?
Why are you using ADODB instead of.NET anyway?
--
Joe ( Microsoft MVP - XML)
|
|

July 24th, 2008, 06:53 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks once again for your reply , but i couldn't find a button to attach the xslt file and the xsd files as well for you to see it , plus if i removed the vbscript i got no error , any way i hope you are not bothered to send the xslt file inline like this
<?schema_locations source_url="" source_root="msg" destination_url="" destination_root="msg"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msg="http://Epicor.com/InternalMessage/1.1" xmlns:dta="http://www.scala.net/AccountingDimension/1.1" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:vbs="urn:schemas-sqlxml-org:vbs">
<xsl:output method="xml" version="1.0" indent="yes" omit-xml-declaration="no"></xsl:output>
<xsl:include href="parameters.xslt"></xsl:include>
<xsl:template match="/">
<xsl:apply-templates select="*"></xsl:apply-templates>
</xsl:template>
<xsl:template match="msg:msg">
<xsl:element name="msg:msg">
<xsl:for-each select="msg:req">
<xsl:element name="msg:req">
<xsl:if test="msg:ctx/*">
<xsl:element name="msg:ctx">
<xsl:copy-of select="msg:ctx/*"></xsl:copy-of>
</xsl:element>
</xsl:if>
<xsl:element name="msg:dta">
<xsl:for-each select="msg:dta/dta:AccountingDimension">
<xsl:element name="dta:AccountingDimension">
<xsl:if test="dta:AccDimNum">
<xsl:element name="dta:AccDimNum">
<xsl:value-of select="dta:AccDimNum"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:AccDimCode">
<xsl:element name="dta:AccDimCode">
<xsl:value-of select="dta:AccDimCode"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:Manager">
<xsl:element name="dta:Manager">
<xsl:value-of select="dta:Manager"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:Closed">
<xsl:element name="dta:Closed">
<xsl:value-of select="dta:Closed"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:Category">
<xsl:element name="dta:Category">
<xsl:value-of select="dta:Category"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo1">
<xsl:element name="dta:ReportTo1">
<xsl:value-of select="dta:ReportTo1"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo2">
<xsl:element name="dta:ReportTo2">
<xsl:value-of select="dta:ReportTo2"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo3">
<xsl:element name="dta:ReportTo3">
<xsl:value-of select="dta:ReportTo3"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo4">
<xsl:element name="dta:ReportTo4">
<xsl:value-of select="dta:ReportTo4"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo5">
<xsl:element name="dta:ReportTo5">
<xsl:value-of select="dta:ReportTo5"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportLevel">
<xsl:element name="dta:ReportLevel">
<xsl:value-of select="dta:ReportLevel"></xsl:value-of>
<xsl:value-of select="vbs:UpdateCOA(string(dta:AccDimCode), string(dta:ForeignDescrList/dta:ForeignDescr/dta:Name), string(dta:Manager), string(dta:Closed), string(dta:Category), string(dta:ReportTo1), string(dta:ReportTo2), string(dta:ReportTo3), string(dta:ReportTo4), string(dta:ReportTo5), string(dta:ReportLevel), string(dta:AutoAllocNum), string(dta:AutoAccrual), string(dta:AccrualAcc), string(dta:AccrualYear), string(dta:AccrualPer), string(dta:UsrGrp), $companyCode, $dbEngine)"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:AutoAllocNum">
<xsl:element name="dta:AutoAllocNum">
<xsl:value-of select="dta:AutoAllocNum"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:AutoAccrual">
<xsl:element name="dta:AutoAccrual">
<xsl:value-of select="dta:AutoAccrual"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:AccrualAcc">
<xsl:element name="dta:AccrualAcc">
<xsl:value-of select="dta:AccrualAcc"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:AccrualYear">
<xsl:element name="dta:AccrualYear">
<xsl:value-of select="dta:AccrualYear"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:AccrualPer">
<xsl:element name="dta:AccrualPer">
<xsl:value-of select="dta:AccrualPer"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:element name="dta:UsrGrp">
<xsl:variable name="convVar_1">
<xsl:value-of select="dta:UsrGrp"></xsl:value-of>
</xsl:variable>
<xsl:choose>
<xsl:when test="$convVar_1 = "ADMINS"">
<xsl:text>10</xsl:text>
</xsl:when>
<xsl:when test="$convVar_1 = "Root"">
<xsl:text>0</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:element>
<xsl:element name="dta:ForeignDescrList">
<xsl:element name="dta:ForeignDescr">
<xsl:if test="dta:ForeignDescrList/dta:ForeignDescr/dta:Name">
<xsl:element name="dta:Name">
<xsl:value-of select="dta:ForeignDescrList/dta:ForeignDescr/dta:Name"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:element name="dta:DescrLines">
<xsl:for-each select="dta:ForeignDescrList/dta:ForeignDescr/dta:DescrLines/dta:DescrLine">
<xsl:if test=".">
<xsl:element name="dta:DescrLine">
<xsl:value-of select="."></xsl:value-of>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
<xsl:element name="msg:wfl">
<xsl:if test="msg:wfl/msg:usr/*">
<xsl:element name="msg:usr">
<xsl:copy-of select="msg:wfl/msg:usr/*"></xsl:copy-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:ElemID">
<xsl:element name="msg:ElemID">
<xsl:value-of select="msg:wfl/msg:ElemID"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:PrcID">
<xsl:element name="msg:PrcID">
<xsl:value-of select="msg:wfl/msg:PrcID"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:SubWF/*">
<xsl:element name="msg:SubWF">
<xsl:copy-of select="msg:wfl/msg:SubWF/*"></xsl:copy-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:RefID">
<xsl:element name="msg:RefID">
<xsl:value-of select="msg:wfl/msg:RefID"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:Task/*">
<xsl:element name="msg:Task">
<xsl:copy-of select="msg:wfl/msg:Task/*"></xsl:copy-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:Ack">
<xsl:element name="msg:Ack">
<xsl:value-of select="msg:wfl/msg:Ack"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:MsgType">
<xsl:element name="msg:MsgType">
<xsl:value-of select="msg:wfl/msg:MsgType"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:Action">
<xsl:element name="msg:Action">
<xsl:value-of select="msg:wfl/msg:Action"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="msg:wfl/msg:DataPaging/*">
<xsl:element name="msg:DataPaging">
<xsl:copy-of select="msg:wfl/msg:DataPaging/*"></xsl:copy-of>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:for-each>
<xsl:if test="msg:trc/*">
<xsl:element name="msg:trc">
<xsl:copy-of select="msg:trc/*"></xsl:copy-of>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<msxsl:script language="VBScript" implements-prefix="vbs"><![CDATA[
Function UpdateCOA(AccDimCode,Name,manager,closed,category, Rep1,Rep2,Rep3,Rep4,Rep5,RepLevel,AllocNum,AutoAcc ,AccrualAcc,AccrualYear,AccrualPer,UsrGrp,cc,db)
'Function to get EAN code from Stock Item and replace that stock code with the EAN
' Function to get EAN code from Stock Item and replace that stock code with the EAN
dsn = "Provider=SQLOLEDB;Trusted_Connection=yes; Data Source="+db+"; Initial Catalog=ScaSystemDB;" +_
" user id='user'; password='pwd'"
set cn= createObject("ADODB.connection")
cn.open dsn
sqlStmt = "select DBName from ScaCompanies where CompanyCode = '"&cc&"'"
Set recData = CreateObject("ADODB.Recordset")
recData.open sqlStmt,cn
if not recData.EOF then databaseName = recData(0)
recData.close
cn.close
dsn = "Provider=SQLOLEDB;Trusted_Connection=yes; Data Source="+db+"; Initial Catalog=" +_
databaseName+"; user id='user'; password='pwd'"
set cn=createObject("ADODB.connection")
cn.open dsn
' Check for OVT code
accountexists = 0
Set recData = CreateObject("ADODB.Recordset")
sqlStmt = "Update GL03"+cc+"06 Set GL03003 = '"+ Name +"' , GL03006 = '"+ manager +"' , GL03007 = '" + closed + "', GL03008 = '" + category +_
"', GL03009 = '" + Rep1 + "' , GL03010 = '" + Rep2 + "', GL03011 = '" + Rep3 + "', GL03012 = '" + Rep4 + "', GL03013 = '" + Rep5 +_
"' , GL03014 = '" + RepLevel + "', GL03015 = '" + AllocNum + "' , GL03016 = '" + AutoCc +_
" ', GL03017 = '"+ AccrualAcc +"', GL03018 = '" + AccrualYear+ "', GL03019 = '"+ AccrualPer + "',GL03020 = '" + UsrGrp + "' WHERE GL03001 = '" + AccDimCode + "'"
recData.open sqlStmt,cn
if not recData.EOF then
if Len(recData(0)) > 0 then
TmpSupplier = recData(0)
else
TmpSupplier = supplier
end if
end if
recData.Close
cn.close
UpdateCOA = sqlStmt
End Function]]></msxsl:script>
</xsl:stylesheet>
|
|

July 24th, 2008, 07:07 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Well I suggest you try what I said last time, save the script to a .vbs file, add any necessary infrastructure and run it. Then you might get an error message with some contextual information and you'll know which of the two operations is failing and you start to debug properly.
In my opinion this code shouldn't be running inside an XSLT anyway. Much better to have some sort of service that returns the data and include it in the XSLT using the document function or as a global parameter.
--
Joe ( Microsoft MVP - XML)
|
|

July 24th, 2008, 09:44 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
I can't help you get your Javascript working (you're on the wrong forum for that), but I can make some suggestions about your XSLT.
This code:
<xsl:if test="dta:Category">
<xsl:element name="dta:Category">
<xsl:value-of select="dta:Category"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo1">
<xsl:element name="dta:ReportTo1">
<xsl:value-of select="dta:ReportTo1"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo2">
<xsl:element name="dta:ReportTo2">
<xsl:value-of select="dta:ReportTo2"></xsl:value-of>
</xsl:element>
</xsl:if>
<xsl:if test="dta:ReportTo3">
<xsl:element name="dta:ReportTo3">
<xsl:value-of select="dta:ReportTo3"></xsl:value-of>
</xsl:element>
</xsl:if>
can almost certainly (making some assumptions about your source XML) be replaced by
<xsl:copy-of select="dta:Category"/>
<xsl:copy-of select="dta:Report1"/>
<xsl:copy-of select="dta:Report2"/>
<xsl:copy-of select="dta:Report3"/>
or in XSLT 2.0
<xsl:copy-of select="dta:Category, dta:Report1, dta:Report2, dta:Report3"/>
(I hope you aren't paid according to the number of lines of code you write).
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
|
|

July 24th, 2008, 11:34 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
first i am new to xslt and i don't know if my platform is supporting the dotnet or not as this a product by our company for ERP systems to connect to each other and i don't know if they support dotnet or not , the msxml found on my machine is msxml 6.0 , can you guide me where i can read more about the xslt rather than w3schools
but i realized one thing when i tried to intialise my connection and record set with Dim xxx as new ADODB.Connection , he gave me compilation error , do you have any clue , please be notified that am new to the product and to xslt as well , and i do really appreciate your help and effor to solve this problem with me
|
|

July 24th, 2008, 11:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
My last post on this thread as you seem to ignore my suggestions but as you're using VBScript, which is weakly typed, you can't write "as New ADODB.Connection". You just use "Dim xxx". That's why you should debug this as a standalone script, you'd get proper error messages and line numbers as well as being able to step through the code in a debugger.
--
Joe ( Microsoft MVP - XML)
|
|
 |