I'm trying to parse a line from a text file (.svm file) but when the text
contains the characters & or < or > the text doesn't get parsed.
It works fine if the text doesn't contain those 3 characters however.
Whats the problem? Why won't it recognize those 3 characters?
The line to parse is
Notes=" any characters "
I made the function match everything between the quotes
and if nothing is between the quotes is will return **No Notes**
The output is xsl stylesheet:Code:function findnotes( notes ) { var notes // if no match, use this var notesArray = notes.match(/".+"/gi); if (notesArray) { notes = ""; for (var i = 0; i < notesArray.length; i++) { notes += notesArray[i]; } } else { notes = "**No Notes**"; } return notes; } function convert_SVM_to_XML( p_inp, p_t ) { sXML = ""; sXML += "<svm>"; fso = new ActiveXObject( "Scripting.FileSystemObject" ); try { tfRead = fso.OpenTextFile( p_inp.value, 1/*for reading*/, false ); } catch(e) { alert("Hey Dumb Dumb! You need to browse for a setup!"); return; } while ( !tfRead.AtEndOfStream ) { s = tfRead.ReadLine(); if( s == "[GENERAL]" ) { s = tfRead.ReadLine(); sXML += "<par name='Notes'>" + findnotes( s ) + "</par>"; s = tfRead.ReadLine();
Code:function showPar( pmode, pdescname, pparname, punit, ponlyDiff ) { ps = ""; if(( pmode == 1 ) || ( pmode == 2 )) ps+=" "+pdescname+" <a style='font-size: 12px; font-weight:bold; color:"+arrColors[pmode]+";'><xsl:value-of select='svms/svm[1]/par[@name=\""+pparname+"\"]'/></a> "+punit+"<br/>"; else { if( ponlyDiff == 1 ) { ps+=" <xsl:if test='svms/svm[1]/par[@name=\""+pparname+"\"] != svms/svm[2]/par[@name=\""+pparname+"\"]'>"; ps+=" "+pdescname+" <a style='font-size: 12px; font-weight:bold; color:"+arrColors[1]+";'><xsl:value-of select='svms/svm[1]/par[@name=\""+pparname+"\"]'/></a> <b>/</b> <a style='font-size: 12px; font-weight:bold; color:"+arrColors[2]+";'><xsl:value-of select='svms/svm[2]/par[@name=\""+pparname+"\"]'/></a> "+punit+"<br/>"; ps+=" </xsl:if>"; } else { ps+=" <xsl:choose>"; ps+=" <xsl:when test='svms/svm[1]/par[@name=\""+pparname+"\"] != svms/svm[2]/par[@name=\""+pparname+"\"]'>"; ps+=" "+pdescname+" <a style='font-size: 12px; font-weight:bold; color:"+arrColors[1]+";'><xsl:value-of select='svms/svm[1]/par[@name=\""+pparname+"\"]'/></a> <b>/</b> <a style='font-size: 12px; font-weight:bold; color:"+arrColors[2]+";'><xsl:value-of select='svms/svm[2]/par[@name=\""+pparname+"\"]'/></a> "+punit+"<br/>"; ps+=" </xsl:when>"; ps+=" <xsl:otherwise>"; ps+=" "+pdescname+" <a style='font-size: 12px; font-weight:normal;'><xsl:value-of select='svms/svm[1]/par[@name=\""+pparname+"\"]'/></a> <b>/</b> <a style='font-size: 12px; font-weight:normal;'><xsl:value-of select='svms/svm[2]/par[@name=\""+pparname+"\"]'/></a> "+punit+"<br/>"; ps+=" </xsl:otherwise>"; ps+=" </xsl:choose>"; } } return ps; } function showFile( mode, onlyDiff ) { oxml = new ActiveXObject('Microsoft.XMLDOM'); oxml.async = false; strXML1 = ""; strXML2 = ""; if(( mode == 1 ) || ( mode == 3 )) { strXML1 = convert_SVM_to_XML( document.all.inpFile1 ); } if(( mode == 2 ) || ( mode == 3 )) { strXML2 = convert_SVM_to_XML( document.all.inpFile2 ); } oxml.loadXML( "<?xml version='1.0'?><svms>" + strXML1 + strXML2 + "</svms>" ); //alert(oxml.xml); var xsldom=new ActiveXObject("Microsoft.XMLDOM"); xsldom.async=false; strxsl=""; strxsl+="<?xml version='1.0'?>"; strxsl+="<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='3.0'>"; strxsl+="<xsl:template match='/'>"; strxsl+=" <table border='1' width='100%' style='background-color: black' height='100%' cellpadding='1' cellspacing='1' align='center'>"; strxsl+=" <tr>"; strxsl+=" <td align='right'>"; strxsl+=" <table width='240' height='100' style='background-color: gray' cellpadding='0' cellspacing='0' border='0'>"; strxsl+=" <tr height='20'><td>"; strxsl+=" <table cellpadding='2' cellspacing='1' width='100%' border='0' height='100%'>"; strxsl+=" <tr>"; strxsl+=" <td align='center' style='font-family: arial; font-size: 13px; font-weight: bold; color: #FFFFFF; background-color: gray;'>"; strxsl+=" SETUP NOTES"; strxsl+=" </td>"; strxsl+=" </tr>"; strxsl+=" </table>"; strxsl+=" </td></tr>"; strxsl+=" <tr><td>"; strxsl+=" <table cellpadding='2' cellspacing='1' width='100%' height='100%' border='0'>"; strxsl+=" <tr>"; strxsl+=" <td valign='top' style='font-family: Arial; font-size: 11px; font-weight: normal; color: black; background-color: white;'>"; strxsl+= showPar( mode, "", "Notes", "", onlyDiff );



Reply With Quote

For example:


Bookmarks