Tuesday

javascript transformnode or javascript transform xml

XSL transformation in javascript


// ake xmldoc for client -side transformations
function MakeXMLDoc()
{
var xmlDoc;
// code for IE
if (window.ActiveXObject){
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
xmlDoc=document.implementation.createDocument("","",null);

}else{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;

return(xmlDoc);
}


function XSLTrasformer(xml,xsl,span_name) // >[:>]
{

//xml=loadXMLDoc("1.xml");
//xsl=loadXMLDoc("NovaSettleResponse.xsl");

// code for IE
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById(span_name).innerHTML=ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation
&& document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById(span_name).appendChild(resultDocument);
}

}

function XMLPopup(xml_string,xsl_file){
xsl=MakeXMLDoc(); xml=MakeXMLDoc();
xsl.load(xsl_file);
xml.loadXML(xml_string);
ex=xml.transformNode(xsl);
//document.getElementById(span_name).innerHTML=ex;
var dbgwin;
//left=0,top=0,
dbgwin=window.open("", "xml_pop", "width=420,height=540,scrollbars=yes,status=yes,resizable=yes");
dbgwin.document.write(ex);
dbgwin.document.write("<p><input type='button' onclick='window.close();' value='close'></p>");
}

call web service from classic asp or vb6 (SOAP Toolkit 3.0)

1.download and install SOAP Toolkit 3.0 from microsoft website
2.here is sample of calling asp.net web service from classic asp:
on this sample XML returning from one of services methods will transformed by xslt and writed on page.
<%
Dim SoapClient
Application.Lock

Set SoapClient = Server.CreateObject("MSSOAP.SoapClient30")
SoapClient.ClientProperty("ServerHTTPRequest") = True
'production url
SoapClient.MSSoapInit "https://services.server.com/clientalerts/alert.asmx?WSDL"
'add
Set Application("CalcRpcAspVbsClient") = SoapClient
Application("CalcRpcAspVbsClientInitialized") = True


Application.UnLock

'call as usual
Response.Write SoapClient.Transformdata("c:\xslt\setup.xslt", SoapClient.getSubscriptions(Session("DealerId")))%>



more...

System.Web.HttpException: Maximum request length exceeded

to fix this exception add line to web.config :

<httpRuntime maxRequestLength="81920" executionTimeout="900" />
</system.web>
</configuration>

Transferring large objects over webservice (MSDN)

more...

Monday

System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

[Web Service in .net , webservice security]
when call webservice with bad certificate (VB.NET)

1.Add imports
Imports System.Net.Security
Imports System.Security.Cryptography.X509Certificates

2.before calling webservice:
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf customXertificateValidation)

3.Custom certificate runner:
Private Shared Function customXertificateValidation(ByVal sender As Object, ByVal cert As X509Certificate, ByVal chain As X509Chain, ByVal Errora As SslPolicyErrors) As Boolean
Return True
End Function


more...

Saturday

Autojump: Jumping game script : autohotkey

SetKeyDelay, 75, 75

;Exits AutoHotKey application.
$^CapsLock::
ExitApp
return

;Pauses AutoHotKey Script.
F6::Pause, Toggle, 1


$x::
Loop {
Send, {Space}
sleep 60
Send, {Space}
sleep 60
Send, {Space}
sleep 60
Send, {Space}
}

more...

Wednesday

Ho wto fix "the definition of object * has changed since it was compiled." error:

run fololowing :
exec sp_recompile sp_your_name
OUTPUT:
Object 'sp_yourname' was successfully marked for recompilation.

more...

Tuesday

make xsd from xml (C#/csharp)


[Test]
public void generateXsd() {
DataSet d = new DataSet();
d.ReadXml(@"C:\projects\LeadInformation.xml");
d.WriteXmlSchema(@"C:\projects\LeadInformation.xsd");
}

more...

Thursday

grep how to find recursively all files with keywords from keyword file

assume that kw.txt is text file with keywords we have to find , then :
grep -irn -f ../kw.txt . *
more...

TSQL:MS SQL SERVER:Find stored procedure by keyword or column



SELECT sys.sysobjects.name, sys.syscomments.text
FROM sys.sysobjects INNER JOIN syscomments
ON sys.sysobjects.id = sys.syscomments.id
WHERE sys.syscomments.text LIKE '%single_pay_renew%'
AND sys.sysobjects.type = 'P'
ORDER BY sys.sysobjects.NAME


more...

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...