-- 作者:wangjianredfox
-- 发布时间:6/4/2006 1:04:00 PM
-- 谁能帮我看看......
rect.dtd <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT FigBody (Rect+)> <!ELEMENT Rect (RPoint,RWidth,RHeight,RAngle)> <!ATTLIST Rect id ID #REQUIRED> <!ELEMENT RPoint (RPabscissa,RPordinate)> <!ATTLIST RPoint id ID #REQUIRED> <!ELEMENT RPabscissa (#PCDATA)> <!ELEMENT RPordinate (#PCDATA)> <!ELEMENT RWidth (#PCDATA)> <!ELEMENT RHeight (#PCDATA)> <!ELEMENT RAngle (#PCDATA)> rect.xml <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by () --> <!DOCTYPE FigBody SYSTEM "rect.dtd"> <FigBody> <Rect id="rect01"> <RPoint id="point01"> <RPabscissa>50</RPabscissa> <RPordinate>50</RPordinate> </RPoint> <RWidth>200</RWidth> <RHeight>300</RHeight> <RAngle>0</RAngle> </Rect> <Rect id="rect02"> <RPoint id="point02"> <RPabscissa>80</RPabscissa> <RPordinate>80</RPordinate> </RPoint> <RWidth>400</RWidth> <RHeight>200</RHeight> <RAngle>0</RAngle> </Rect> </FigBody> add.htm 添加矩形的操作界面 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>test!!!!</title> <meta http-equiv="Content-Type" content="text/html;charset=gb2312"> <style type="text/css"> <!-- input{font-size:9pt;} A:link{text-decoration:none;font-size:9pt;color:000000} A:visited{text-decoration:none;font-size:9pt;color:000059} A:active{text-decoration:none;font-size:9pt} A:hover{text-decoration:none;color:red} body,table{font-size:9pt} tr,td{font-size:9pt} body { background-image: url(); background-color: #73BFA7; } .style1 {color: #0000FF} --> </style> </head> <body Text="#000000" link="#0000ff" vlink="#0000ff"> <CENTER class="style1"> <h1>welcome to my world!</h1> <h3><a href="rect.svg">have a look!</a></h3> <p> <h3>add elements!</h3> <p> <FORM METHOD=POST ACTION="rect.asp"> <table border=2 bordercolor="#009900"> <tr> <td> <table width=600 cellspacing=2 cellpadding=3> <tr> <td align=right>id of rect: </td> <td><input type=text name="rect_id" maxlength=30></td> </tr> <tr> <td align=right>id of point:</td> <td><input type=text name="point_id" maxlength=30></td> </tr> <tr> <td align=right>RPabscissa of point:</td> <td><input type=text name="point_x" maxlength=30></td> </tr> <tr> <td align=right>RPordinate of point:</td> <td><input type=text name="point_y" maxlength=30></td> </tr> <tr> <td align=right>RWidth of rect:</td> <td><input type=text name="rect_width" maxlength=30></td> </tr> <tr> <td align=right>RHeight of rect:</td> <td><input type=text name="rect_height" maxlength=30></td> </tr> <tr> <td align=right>angle of rect:</td> <td><input type=text name="rect_angle" maxlength=30></td> </tr> <tr> <td><input type=submit value="add a rect"></td> </tr> </TABLE> </td> </tr> </table> </FORM> </CENTER> </body> </html> rect.asp 用dom对xml操作 <html> <head> <title>adding is sucessful!</title> <meta http-equiv="Content-Type" content="text/html;charset=gb2312"> <style type="text/css"> <!-- input{font-size:9pt} A:link{text-decoration:none;font-size:9pt;color:000000} A:visited{text-decoration:none;font-size:9pt;color:000059} A:active{text-decoration:none;font-size:9pt} A:hover{text-decoration:none;color:red} body,table{font-size:9pt} tr,td{font-size:9pt} body{background-color:#FFCCCC;} .style1 {color:#ECE9D8} body,td,th{ color:#009933; } --> </sytle> </head> <% //定义变量 Dim srect_id Dim spoint_id Dim spoint_x Dim spoint_y Dim srect_width Dim srect_height Dim sredt_angle //自定义xmldom变量 Dim oDOM Dim oRootNode Dim oEntryNode Dim oDetailsNode Dim ochildsnode //从add.htm文件中取得参数 srect_id=Request("rect_id") spoint_id=Request("point_id") spoint_x=Request("point_x") spoint_y=Request("point_y") srect_width=Request("rect_width") srect_height=Request("rect_height") srect_angle=Request("rect_angle") //create dom object Set oDOM=Server.CreateObject("Microsoft.XMLDOM") oDOM.async=false oDOM.load(server.mappath("rect.xml")) //查看是否找到 If oDOM.parseError.ErrorCode<>0 Then 'not found!create an empty documen oDOM.loadXML "<FigBody/>" End If //找到插入节点 Set oEntryNode=oDOM.documentElement.AppendChild(oDOM.createElement("Rect")) oEntryNode.setAttribute "id",srect_id set oDetailsNode=oEntrynode.appendchild(oDOM.createElement("RPoint")) oDetailsNode.setAttribute"id",spoint_id set ochildsnode=oDetailsNode.appendchild(oDOM.createElement("RPabscissa")) ochildsnode.text=spoint_x set ochildsnode=oDetailsNode.appendchild(oDOM.createElement("RPordinate")) ochildsnode.text=spoint_y set oDetailsNode=oEntrynode.appendchild(oDOM.createElement("RWidth")) oDetailsNode.text=srect_width set oDetailsNode=oEntrynode.appendchild(oDOM.createElement("RHeight")) oDetailsNode.text=srect_height set oDetailsNode=oEntrynode.appendchild(oDOM.createElement("RAngle")) oDetailsNode.text=srect_angle oDOM.save(server.mappath("rect.xml")) %> <h2>增加<%=srect_id%>over</h2> <p> <p><a href="rect.svg" class="style1">have a look</a></p> </html> rect.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" encoding="UTF-16" version="1.0" standalone="no" media-type="image/svg+xml" /> <xsl:template match="/"> <svg width="1000" height="1000"> <g id="rects" style="stroke:#000000"> <xsl:for-each select="FigBody/Rect"> <xsl:variable name="rect_id" select="@id"/> <xsl:variable name="rw" select="RWidth"/> <xsl:variable name="rh" select="RHeight"/> <xsl:variable name="ra" select="RAngle"/> <xsl:for-each select="FigBody/Rect/RPoint"> <xsl:variable name="px" select="RPabscissa"/> <xsl:variable name="py" select="RPordinate"/> <rect id="rect_id" x="{$px}" y="{$py}" rx="{$ra}" ry="{$ra}" width="{$rw}" height="{$rh}" style="fill:blue"> </rect> </xsl:for-each> </xsl:for-each> </g> </svg> </xsl:template> </xsl:stylesheet> show.asp 显示svg图形 <%@ Language="VBScript"%> <% Response.Clear Response.Buffer = True Dim xmldoc Dim xsldoc Dim strResult Response.ContentType = "image/svg+xml" set xmldoc = Server.CreateObject("MSXML2.DOMDOCUMENT.4.0") xmldoc.async = false xmldoc.load Server.MapPath("rect.xml") set xsldoc = Server.CreateObject("MSXML2.DOMDOCUMENT.4.0") xsldoc.async = false xsldoc.load Server.MapPath("rect.xsl") strResult=xmldoc.transformNode(xsldoc) strResult=Replace(strResult,"UTF-16","UTF-8") Response.Write strResult %> 对xml的操作没有什么问题,可是想动态显示rect就不行了,不知道为什么,请高手帮我,试了xalan也不行,帮我看看哪的问题
|