473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

XSl transformation not happening in asp page

Hi Gurus,

I have a problem with the way my output gets displayed in my asp page
I have the UI in ASP which asks for input from a user on the asp page
and then passes that data to a perl file which further processes it and
passes it back to the asp in an xml format
Finally the asp page has to open the output in html in the same page.
The created xml file has the details to the xsl stylesheet .
but presently the o/p gets diaplyed in an xml format in the asp and not
in a html format
<?xml version="1.0"?>
<?xml-stylesheet .......
<component>.....</component>

I do know that when this output file is opened in a browser it is a
neatly (xsl) transformed page
how do i make the output also appear the same way in my asp page
can i force the asp to understand it as a html?

I am presently doing this in my asp
Response.Write "receive: "&objXMLHTTP.status&"
"&objXMLHTTP.statusText&"<xmp>"&objXMLHTTP.Respons eText&"</xmp>"
Please advise
Thanks in advance
Nivi

Jul 7 '06 #1
2 1269

"nivi" <Ni****************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi Gurus,

I have a problem with the way my output gets displayed in my asp page
I have the UI in ASP which asks for input from a user on the asp page
and then passes that data to a perl file which further processes it and
passes it back to the asp in an xml format
Finally the asp page has to open the output in html in the same page.
The created xml file has the details to the xsl stylesheet .
but presently the o/p gets diaplyed in an xml format in the asp and not
in a html format
<?xml version="1.0"?>
<?xml-stylesheet .......
<component>.....</component>

I do know that when this output file is opened in a browser it is a
neatly (xsl) transformed page
The transform is here being performed by the browser. The server has simply
sent the XML.
how do i make the output also appear the same way in my asp page
can i force the asp to understand it as a html?

I am presently doing this in my asp
Response.Write "receive: "&objXMLHTTP.status&"
"&objXMLHTTP.statusText&"<xmp>"&objXMLHTTP.Respons eText&"</xmp>"
Again the ResponseText will simply contain XML text.
>

Please advise
Thanks in advance
Nivi
If you want to perform the transform on your ASP server you will need to
execute it yourself.
I'll assume the remote server has specified the content type it is send is
"text/xml" therefore the ResponseXML property should return an XML DOM.

Dim oNode
Dim sTransformResult
Dim sTransformHref

Set xml = objXMLHTTP.ResponseXML

sTransformHRef = "<url goes here" 'Replace with the URL to the XSL

Set xsl = Server.CreateObject("MSXML2.DOMDocument.3.0")
xsl.async = false
xsl.setProperty "ServerHTTPRequest", True
xsl.load sTransformHref

sTransformResult = oDOM.transformNode(xsl)
Of course this presupposes that you know what the value of sTransformHref
will be. If not then it needs to be
harvested from the xml-stylesheet processing instruction in the DOM and then
resolved to a full URL. Thats a lot more work. Add these functions to your
page:-

Function GetStyleSheetHRef(roDOM)

Dim roDOM

For Each oNode in roDOM.childNodes
If oNode.nodeTypeString = "processinginstruction" Then
If oNode.nodeName = "xml-stylesheet" Then
GetStyleSheetHRef = ExtractHREF(oNode.nodeValue)
Exit For
End If
End If
Next

End Function

Function ExtractHREF(rsValue)
Dim rgx
Dim oMatches

Set rgx = New RegExp
rgx.pattern = "href=""(.*?)"""
rgx.IgnoreCase = True

Set oMatches = rgx.Execute(rsValue)
If oMatches.Count 0 Then
ExtractHREF = oMatches.Item(0).SubMatches(0)
End If

End Function

Function ResolvePath(rsOriginalPath, rsNewPath)

Dim rgx
Dim oOrigMatch
Dim oNewMatch

Set rgx = New RegExp
rgx.pattern = "(https?\://.+?(?=/))?((?:.*/)*)(.*)$"
rgx.IgnoreCase = True

oNewMatch = rgx.Execute(rsNewPath)(0)
oOrigMatch = rgx.Execute(rsOriginalPath)(0)

If oNewMatch.SubMatches(0) <"" Then
ResolvePath = rsNewPath
ElseIf oNewMatch.SubMatches(1) = "" Then
ResolvePath = oOrigMatch.SubMatches(0) & oOrigMatch.SubMatches(1) &
rsNewPath
ElseIf Left(oNewMatch.SubMatches(1),1) <"/" Then
ResolvePath = oOrigMatch.SubMatches(0) & oOrigMatch.SubMatches(1) &
rsNewPath
Else
ResolvePath = oOrigMatch.SubMatches(0) & rsNewPath
End If

End Function
Obviously you will have the URL to the original XML you've retrieved and
given that you have that in a variable called sOriginalHRef you can use this
line of code to resolve sTransformHRef:-

sTransformHRef = ResolvePath(sOriginalHRef, GetStyleSheetHRef(xml))

Note this is untested code and doesn't handle exceptionals well.

HTH,

Anthony.
Jul 8 '06 #2
Hi Anthony,
Thanks a lot for the ideas and the code
That worked
I used the method 1, i already had the xsl style sheet
Thanks again,
Nivi

Anthony Jones wrote:
"nivi" <Ni****************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi Gurus,

I have a problem with the way my output gets displayed in my asp page
I have the UI in ASP which asks for input from a user on the asp page
and then passes that data to a perl file which further processes it and
passes it back to the asp in an xml format
Finally the asp page has to open the output in html in the same page.
The created xml file has the details to the xsl stylesheet .
but presently the o/p gets diaplyed in an xml format in the asp and not
in a html format
<?xml version="1.0"?>
<?xml-stylesheet .......
<component>.....</component>

I do know that when this output file is opened in a browser it is a
neatly (xsl) transformed page

The transform is here being performed by the browser. The server has simply
sent the XML.
how do i make the output also appear the same way in my asp page
can i force the asp to understand it as a html?

I am presently doing this in my asp
Response.Write "receive: "&objXMLHTTP.status&"
"&objXMLHTTP.statusText&"<xmp>"&objXMLHTTP.Respons eText&"</xmp>"

Again the ResponseText will simply contain XML text.


Please advise
Thanks in advance
Nivi

If you want to perform the transform on your ASP server you will need to
execute it yourself.
I'll assume the remote server has specified the content type it is send is
"text/xml" therefore the ResponseXML property should return an XML DOM.

Dim oNode
Dim sTransformResult
Dim sTransformHref

Set xml = objXMLHTTP.ResponseXML

sTransformHRef = "<url goes here" 'Replace with the URL to the XSL

Set xsl = Server.CreateObject("MSXML2.DOMDocument.3.0")
xsl.async = false
xsl.setProperty "ServerHTTPRequest", True
xsl.load sTransformHref

sTransformResult = oDOM.transformNode(xsl)
Of course this presupposes that you know what the value of sTransformHref
will be. If not then it needs to be
harvested from the xml-stylesheet processing instruction in the DOM and then
resolved to a full URL. Thats a lot more work. Add these functions to your
page:-

Function GetStyleSheetHRef(roDOM)

Dim roDOM

For Each oNode in roDOM.childNodes
If oNode.nodeTypeString = "processinginstruction" Then
If oNode.nodeName = "xml-stylesheet" Then
GetStyleSheetHRef = ExtractHREF(oNode.nodeValue)
Exit For
End If
End If
Next

End Function

Function ExtractHREF(rsValue)
Dim rgx
Dim oMatches

Set rgx = New RegExp
rgx.pattern = "href=""(.*?)"""
rgx.IgnoreCase = True

Set oMatches = rgx.Execute(rsValue)
If oMatches.Count 0 Then
ExtractHREF = oMatches.Item(0).SubMatches(0)
End If

End Function

Function ResolvePath(rsOriginalPath, rsNewPath)

Dim rgx
Dim oOrigMatch
Dim oNewMatch

Set rgx = New RegExp
rgx.pattern = "(https?\://.+?(?=/))?((?:.*/)*)(.*)$"
rgx.IgnoreCase = True

oNewMatch = rgx.Execute(rsNewPath)(0)
oOrigMatch = rgx.Execute(rsOriginalPath)(0)

If oNewMatch.SubMatches(0) <"" Then
ResolvePath = rsNewPath
ElseIf oNewMatch.SubMatches(1) = "" Then
ResolvePath = oOrigMatch.SubMatches(0) & oOrigMatch.SubMatches(1) &
rsNewPath
ElseIf Left(oNewMatch.SubMatches(1),1) <"/" Then
ResolvePath = oOrigMatch.SubMatches(0) & oOrigMatch.SubMatches(1) &
rsNewPath
Else
ResolvePath = oOrigMatch.SubMatches(0) & rsNewPath
End If

End Function
Obviously you will have the URL to the original XML you've retrieved and
given that you have that in a variable called sOriginalHRef you can use this
line of code to resolve sTransformHRef:-

sTransformHRef = ResolvePath(sOriginalHRef, GetStyleSheetHRef(xml))

Note this is untested code and doesn't handle exceptionals well.

HTH,

Anthony.
Jul 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
7
by: CK | last post by:
Hello, I have the 60 MB XML string and I am coding a program in Visual Basic to run a XSL transformation on it. Currently, I'm using the Microsoft standard MSXML 2.0 to create a DOM document, load...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
6
by: Jain, Pranay Kumar | last post by:
Hi All, We have created a simple application that takes a dataset and generates the data in Excel schema format. It uses an xslt file to do the transformation for excel 2002 and so on. We are...
3
by: Joseph A Romeo | last post by:
I have written an XSLT transformation on an ASP.NET page. The resulting HTML is primarily a table of links. I have found that when the resulting HTML is less than or equal to 16040 bytes, the...
0
by: Joseph A Romeo | last post by:
I have written an XSLT transformation on an ASP.NET page. The resulting HTML is primarily a table of links. I have found that when the resulting HTML is less than or equal to 16040 bytes, the...
0
by: RussellKay | last post by:
To all who might be interested: I have created a CALS to HTML XSL transformation style sheet that converts 98% of the CALS table standard to a HTML equivalent. The XSL Version 1.0 transformation...
0
by: Amit00 | last post by:
Hi, I'm performing an xsl transformation in a page I built, and would like to use some custom controls in it (or asp controls, for that matter). I looked this issue up, and understood that it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.