Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > XSl transformation not happening in asp page

Reply
Thread Tools

XSl transformation not happening in asp page

 
 
nivi
Guest
Posts: n/a
 
      07-07-2006
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

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      07-08-2006

"nivi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
 
 
 
nivi
Guest
Posts: n/a
 
      07-11-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use output of XSL transformation as new XSL stylesheet barney.b@iname.com XML 0 01-16-2006 02:29 PM
XSL transformation not works for code reuse Rushi XML 4 12-05-2005 01:42 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
Timeout on Xsl Transformation George Durzi ASP .Net 0 12-29-2003 07:46 PM
XSL transformation not finding template Kevin Dean XML 4 09-11-2003 09:38 PM



Advertisments