http://cafe.naver.com/q69/62368

xmldom 을 이용한 xml과 xsl 활용 예제


 










xsl_style-zend4u.xsl


<%@ Language="javascript"%>
<%


var sess_Key;
var result_path;
var resultFile;


result_path = "D:\WebResult_XML\"
sess_Key = Request("sess_Key");


 


sess_Key = "D:\web\Result_XML\" + sess_Key + ".xml" ;


//Response.write(sess_Key);


var userAgent = new String(Request.ServerVariables("HTTP_USER_AGENT"));


if(userAgent.indexOf("MSIE 5") >= 0 )
 Response.Redirect ("result.xml");
else
 Response.Write(onServer(sess_Key));


function onServer(val)
{
 var doc, stylesheet;


 doc = Server.CreateObject("microsoft.xmldom");
 stylesheet = Server.CreateObject("microsoft.xmldom");


 if(doc !=null && stylesheet != null)
 {
  doc.async = false;
  stylesheet.async = false;
  doc.load(sess_Key);
  stylesheet.load(Server.MapPath("xsl_style.xsl"));


  if(doc.parseError == 0 && stylesheet.parseError == 0)
   return doc.transformNode(stylesheet);
  else
   return "<html><body>Error loading documents</body></html>" ;
 }
 else
  return "<HTML><BODY>Error creating server-side components</body></html>"; 
}


%>


 


이 내용은 ASP XML 이란 워록스(빨간책)에서 발췌한 내용이다.


XML 파일을 로드 해서, xsl을 입혀 HTML형식으로 내보내는 예제이다.


 


javascript를 잘할 줄 안다면 ASP의 스크립트는 javascript를 사용하는 것도 매리트가 있어 보인다.


관련하여 허접한 xsl 파일도 함께 첨부해서 올려 놓는다.


 


나중에 다 피가 되고 살이 될 것이다.. ㅋㅋ