- From: puja <lalitha_nutakki@hotmail.com>
- Date: Tue, 10 Jul 2001 07:06:21 -0400 (EDT)
- To: <xml-dist-app@w3.org>
- Message-ID: <DAV31x6JSjbnOitUaxA000052bd@hotmail.com>
hai,
i am sending my code where i am getting problems
i am using asp and xsl to transform an xml file.
my original xml
is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="secondxsl.xsl"?>
<query>
<fields>state</fields>
<table>pardetails</table>
<conditions>
<condition>
<attribute>state</attribute>
<operator>lessthan</operator>
<value>2</value>
</condition>
</conditions>
</query>
my first xsl is
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="VBScript">
<xsl:script ><![CDATA[
public function tablemapping()
Dim newval
Dim xmlDoc
Dim def
newatr=me.text
newop=me.nextSibling.text
newoperator=getfromdictionary(newop)
newval=me.nextSibling.nextSibling.text
if(newatr="state") then
if newoperator="=" then
tablemapping=newatr&" "&newoperator&" "&newval
else
tablemapping=inserttable(newoperator,newval,0)
end if
else
if newoperator="=" then
tablemapping=newatr&" "&newoperator&" "&newval
else
tablemapping=inserttable(newoperator,newval,1)
end if
end if
end function
public function inserttable(newop,newval,childnumber)
set objxmlDoc=CreateObject("Microsoft.XMLDOM")
objxmlDoc.async="false"
objxmlDoc.load("note1.xml")
set newnode=objxmlDoc.createElement("operator")
set newtext=objxmlDoc.createTextNode(newop)
newnode.appendChild(newtext)
objxmlDoc.documentElement.childNodes(childnumber).childNodes(0).childNodes(2).childNodes(0).childNodes(2).childNodes(0).appendchild(newnode)
set newnode=objxmlDoc.createElement("value")
set newtext=objxmlDoc.createTextNode(newval)
newnode.appendChild(newtext)
objxmlDoc.documentElement.childNodes(childnumber).childNodes(0).childNodes(2).childNodes(0).childNodes(2).childNodes(0).appendchild(newnode)
inserttable=objxmlDoc.documentElement.childNodes(childnumber).childNodes(0).xml
end function
function getfromdictionary(objtext)
dim dictionaryobject
set dictionaryobject=CreateObject("Scripting.Dictionary")
dictionaryobject.Add "equalto","="
dictionaryobject.Add "lessthan","lessthan"
dictionaryobject.Add "greaterthan","greaterthan"
dictionaryobject.Add "lessthanorequal","lessthanequalto"
dictionaryobject.Add "greaterthanorequal","greaterthanequalto"
dictionaryobject.Add "ename","ENAM"
dictionaryobject.Add "eid","ID"
dictionaryobject.Add "esalary","SALARY"
dictionaryobject.Add "edepid","DEPID"
dictionaryobject.Add "state","state"
dim newvalue
newvalue=dictionaryobject.Item(objtext)
getfromdictionary=newvalue
end function
]]></xsl:script>
<xsl:template match ="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match ="query">
<xsl:element name="query">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match ="table">
<xsl:element name="table">
<xsl:value-of select="."/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match ="fields">
<xsl:element name="fields">
<xsl:value-of select="."/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match ="conditions">
<xsl:element name="conditions">
<xsl:attribute name="boolean">
<xsl:value-of select="@boolean"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="condition">
<xsl:element name="condition">
<xsl:attribute name="boolean">
<xsl:value-of select="@boolean"/>
</xsl:attribute>
<xsl:for-each select="attribute">
<xsl:eval>tablemapping</xsl:eval>
</xsl:for-each>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
and note1.xml is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="c.xsl"?>
<match>
<state>
<condition>
<attribute>stateid</attribute>
<operator>in</operator>
<value>
<query>
<fields>stateid</fields>
<table>state</table>
<conditions>
<condition>
<attribute>
stateid
</attribute>
</condition>
</conditions>
</query>
</value>
</condition>
</state>
<priority>
<condition>
<attribute>priority</attribute>
<operator>in</operator>
<value>
<query>
<fields>priority</fields>
<table>priority</table>
<conditions>
<condition>
<attribute>
priorityid
</attribute>
</condition>
</conditions>
</query>
</value>
</condition>
</priority>
</match>
and my asp is
<%@ Language=VBScript %>
<%
dim objxml
dim objxsl
dim newxml
dim bflag
dim szXMLGenerated
set objxml=server.Createobject("Microsoft.XMLDOM")
objxml.async=false
bflag=objxml.load(server.MapPath("state0.xml"))
If bflag=false then
response.write "XML OBJECTS ARE NOT LOADED PROPERLY"
End if
set objxsl=server.Createobject("Microsoft.XMLDOM")
objxsl.async=false
bflag=objxsl.load(server.MapPath("secondxsl.xsl"))
if bflag=false then
response.write "XSL OBJECTS ARE NOT LOADED PROPERLY"
end if
szXMLGenerated =objxml.transformNode(objxsl)
Set newxml = Server.CreateObject("Microsoft.XMLDOM")
newxml.async = false
bFlag = newxml.loadXML(szXMLGenerated)
If bFlag = false then
Response.write "XML not loaded"
End if
newxml.save Server.MapPath( "intermediatexml.xml")
set finalxml=server.Createobject("Microsoft.XMLDOM")
finalxml.async=false
bflag=finalxml.load(server.MapPath("intermediatexml.xml"))
if bflag=false then
response.write "XML OBJECTS ARE NOT LOADED PROPERLY"
End if
set firstxsl=server.Createobject("Microsoft.XMLDOM")
firstxsl.async=false
bflag=firstxsl.load(server.MapPath("c1.xsl"))
if bflag=false then
response.write "XSL OBJECTS ARE NOT LOADED PROPERLY"
end if
resultGenerated =finalxml.transformNode(firstxsl)
Response.write resultGenerated
%>
after executing this asp
iam getting output as below
select state from pardetails where ( <condition> <attribute>stateid</attribute> <operator>in</operator> <value> <query> <fields>stateid</fields> <table>state</table> <conditions> <condition> <attribute> stateid </attribute> <operator>lessthan</operator><value>2</value></condition> </conditions> </query> </value> </condition> )
but i want to get it as
select state from pardetails where(stateid in (stateid lessthan 2)
please help to solvu this problem
mail me to:puja_kus@yahoo.com
Received on Tuesday, 10 July 2001 08:58:32 UTC