Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newby question on XSLT

Status
Not open for further replies.

cardy

Technical User
Sep 5, 2000
33
GB
I've been working my way thru' Steve Muench's excellent Building Oracle XML Apps book and was wondering why the following doesn't work as I think it should. I have an XML file, King.xml :

<?xml version=&quot;1.0&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;KingToXML.xsl&quot;?>
<ROWSET>
<ROW>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
</ROW>
</ROWSET>

The KingToXML.xsl stylesheet looks like :

<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot; <xsl:eek:utput method=&quot;xml&quot; indent=&quot;yes&quot;/>
<xsl:template match=&quot;/&quot;>
<Invitation>
<To>
<xsl:value-of select=&quot;ROWSET/ROW/ENAME&quot;/>
<xsl:text> &amp; Family</xsl:text>
</To>
</Invitation>
</xsl:template>
</xsl:stylesheet>

The output I expect is :

<?xml version = '1.0' encoding = 'UTF-8'?>
<Invitation>
<To>KING &#38; Family</To>
</Invitation>

However when I try to view the King.xml file using Internet Explorer 5.5 all I get is :

& Family

Shouldn't Internet Explorer perform the transformation based upon the stylesheet and display the output as expected or am I misunderstanding the use of XSLT.

TIA

Cardy
 
Hello,
The problem with IE is that it cannot do client-side transforming when naming space is used.
The solution is to use some server-side transforming.
The row <?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;KingToXML.xsl&quot;?>
should be deleted from xml file.
For example the following ASP file will do the transformation:
<%
'Load the XML
set oXmlDoc = Server.CreateObject(&quot;MSXML2.DOMdocument&quot;)
oXmlDoc.async = false
oXmLDoc.load(Server.MapPath(&quot;king.xml&quot;))

'Load the XSL
set oXslDoc = Server.CreateObject(&quot;MSXML2.DOMdocument&quot;)
oXslDoc.async = false
oXslDoc.load(Server.MapPath(&quot;KingToXML.xsl&quot;))

'Transform the file
Response.Write(oXmlDoc.transformNode(oXslDoc))
%>

Hope this will help. D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top