[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Output Arrow Symbols - only 2 of 3 methods work ??


Subject: [xsl] Output Arrow Symbols - only 2 of 3 methods work ??
From: jdgarrett@xxxxxxxxxx
Date: Tue, 6 Aug 2002 12:58:11 -0500

So here is the issue:

I am trying to output buttons with arrow symbols
on them (← through ←).

I am able to output buttons with arrows using
Method 1 and Method 2, but not Method 3.
Method 3 just output's question marks.

I need Method 3.



Sincerely
JGarrett
jdgarrett@xxxxxxxxxx

The iMode post in the past couple of weeks
ran into similar obstacle getting only question
marks.

If the "only" answer to this issue is that the
parser loads and parses the xml doc and thereby
changes my original data, then why doesn't it change
it consistently across all methods.



============================================================================
========
Method 1.)

Direct reference of xsl style sheet from within the xml document

Instructions:)
a.) Save xml and xsl source to 1.xml and 1.xsl file
b.) Open 1.xml inside of Internet Explorer

1.xml Source file.)

<?xml version="1.0" encoding="windows-1252"?>
<?xml:stylesheet type="text/xsl" href="1.xsl" ?>
<Company>
 <Part date="2002_0805" time="0730">ABC123</Part>
</Company>

1.xsl Source file.)

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"   xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:template match="/">
<button id="idArrowButtonLeft">&#8592;</button>
<button id="idArrowButtonUp">&#8593;</button>
<button id="idArrowButtonRight">&#8594;</button>
<button id="idArrowButtonDown">&#8595;</button>
</xsl:template>
</xsl:stylesheet>


Method 1 Output.)

You get 4 buttons with each having an arrow symbol

============================================================================
========
============================================================================
========

Method 2.)

Instructions.)

Using JavaScript to load both the xml and xsl source and then create
a processor and then using the transform method, output the resultant
transformation to a div tag to view in the current instance of the browser.
Note: save htmSource into a htm text file then open in browser.
Then save off xml and xsl source in Method 1.
Then open and transform the xml and xsl in Method 1 using the saved
htmSource htm file.

The following is the HTM Source.)

<HTML DIR="LTR">
<HEAD>

<style>
.clsButton1
 {
 background-color:#cacaca;
 font-family: Verdana;
 font-style:;
 font-size:8pt;
 color:#000000;
 text-decoration:none;
 font-weight:;
 cursor:hand;
 }

.clsButton2
 {
 background-color:#ffffff;
 font-family: Verdana;
 font-style:;
 font-size:8pt;
 color:#000000;
 text-decoration:none;
 font-weight:;
 cursor:hand;
 }
</style>


<SCRIPT>

 var XMLFileName = '';
 var XSLFileName = '';

 function LoadFiles()
 {
   XMLFileName  = XMLFile.value;
   XSLFileName  = XSLFile.value;
 }

 function transformXML()
 {

   var objSrcTree = new ActiveXObject('MSXML2.DOMDocument.4.0');
   objSrcTree.setProperty("NewParser", true );
   objSrcTree.async = false;

   var objXSLT = new ActiveXObject('MSXML2.DOMDocument.4.0');
   objXSLT.setProperty("NewParser", true );
   objXSLT.async = false;

   var pbSuccessfulXMLLoad = objSrcTree.load(XMLFileName);


   var pbSuccessfulXSLLoad = objXSLT.load(XSLFileName);


   var strResult = "";
   strResult = objSrcTree.transformNode(objXSLT);
   alert('result = ' + strResult);
   document.getElementById("idDiv").innerHTML = strResult;
 }




</SCRIPT>

</HEAD>

<BODY leftMargin="0" topMargin="0" bgcolor="#FFFFFF" >

<table>
<tr><td><input name="XMLFile" type="file" class="clsButton2"
size="50"></input></td></tr>
<tr><td><input name="XSLFile" type="file" class="clsButton2"
size="50"></input></td></tr>
<tr><td><button class="clsButton1" onClick="LoadFiles()">Load
Files</button></td></tr>
<tr><td><button class="clsButton1" onClick="transformXML()">Transform
XML</button></td></tr>
<tr><td height="50"></td></tr>
</table>


<div id="idDiv"></div>

</BODY>
</HTML>

'//end htmSource


Method 2.) Output: You get 4 buttons with each having an arrow symbol.


============================================================================
=========
============================================================================
=========

Method 3.)

This method will only output question marks.

Note: cut and past into a new VB6 project and then call the function.
Make sure you reference MSXML 4.0 parser in your VB6 references section

// begin visual basic funtion

Public Function OutPutHTMLWithButtons()
On Error GoTo errorhandler

Dim psStrXML As String
Dim psStrXSL As String
Dim pbLoadError As Long
Dim psOutPut As String

Dim XMLDoc As MSXML2.DOMDocument40
Set XMLDoc = New MSXML2.DOMDocument40
XMLDoc.setProperty "NewParser", True
XMLDoc.async = False



Dim XSLDoc As MSXML2.DOMDocument40
Set XSLDoc = New MSXML2.DOMDocument40
XSLDoc.setProperty "NewParser", True
XSLDoc.async = False


psStrXML = "<?xml version=""1.0""?>"
psStrXML = psStrXML & vbCrLf & "<!-- <?xml:stylesheet type=""text/xsl""
href=""1.xsl""?> -->"
psStrXML = psStrXML & vbCrLf & "<Company>"
psStrXML = psStrXML & vbCrLf & "<Part date=""2002_0627""
time=""0730"">ABC123</Part>"
psStrXML = psStrXML & vbCrLf & "</Company>"

pbLoadError = XMLDoc.loadXML(psStrXML)


psStrXSL = "<?xml version=""1.0""?>"
psStrXSL = psStrXSL & vbCrLf & "<xsl:stylesheet
xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""1.0"">"
psStrXSL = psStrXSL & vbCrLf & "<xsl:template match=""/"">"
psStrXSL = psStrXSL & vbCrLf & "<button>&#8592;</button>"
psStrXSL = psStrXSL & vbCrLf & "<button>&#8592;</button>"
psStrXSL = psStrXSL & vbCrLf & "<button>&#8592;</button>"
psStrXSL = psStrXSL & vbCrLf & "<button>&#8592;</button>"
psStrXSL = psStrXSL & vbCrLf & "</xsl:template>"
psStrXSL = psStrXSL & vbCrLf & "</xsl:stylesheet>"



pbLoadError = XSLDoc.loadXML(psStrXSL)

psOutPut = XMLDoc.transformNode(XSLDoc)
MsgBox (psOutPut)

Dim pnFileNum
Dim psFile As String
psFile = App.Path & "\result.htm"
pnFileNum = FreeFile()
Open psFile For Append Access Write As pnFileNum
Print #pnFileNum, psOutPut
Close #pnFileNum

Exit Function
errorhandler:
MsgBox ("error = " & Err.Description)
End Function

//end VisualBasic function
'//==================================================



Method 3 Output.)

When you load the result.htm page, you get 4 buttons with question marks.


Note: if you query the XSLDoc after loadXML you get

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <button>?</button>
        <button>?</button>
        <button>?</button>
        <button>?</button>
    </xsl:template>
 </xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords