新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → xml+xsl树,带checkbox的问题 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2304 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: xml+xsl树,带checkbox的问题 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     xjyanxml 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:0
      积分:54
      门派:XML.ORG.CN
      注册:2004/11/16

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xjyanxml发送一个短消息 把xjyanxml加入好友 查看xjyanxml的个人资料 搜索xjyanxml在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xjyanxml的博客楼主
    发贴心情 xml+xsl树,带checkbox的问题

    tree.xml

    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type='text/xsl' href='tree.xsl'?>
    <TreeView>
      <Tree Text="根节点" id="0001">
       <Tree Text="1.1" id="0002" Expanded="true">
        <Tree Text="1.1.1" id="0003">
         <Tree Text="1.1.1.1" id="0004">
          <Tree  Text="1.1.1.1.1"   id="0004" />
          <Tree Text="1.1.1.1.2" id="0005"/>
         </Tree>
         <Tree Text="1.1.1.2" id="0006"/>
        </Tree>
        <Tree Text="1.1.2" id="0007"/>
       </Tree>
       <Tree Text="1.2" id="0008">
        <Tree Text="1.2.1" id="0009"/>
        <Tree Text="1.2.2" id="0010"/>
       </Tree>
      </Tree>
    </TreeView>
    =============================================
    tree.xsl

    <?xml version="1.0" encoding="gb2312"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <script>
    <xsl:comment>
    <![CDATA[
    var CurrentNode = null;
    var iconLeaf = "<span class='clsLeaf'>.</span>";
    var iconExpand = "<span class='clsExpand'>-</span>";
    var iconCollapse = "<span class='clsCollapse'>+</span>";

    function Expand(obj)
    {
    var div = null;
    var img = obj;
    if(obj.tagName != 'SPAN' || obj.className!='clsSpace')
    return (false);
    obj = obj.parentElement;
    var childRen=obj.children;
    for (var i=0;i < childRen.length;i++)
    {
    if(childRen[i].tagName == 'DIV'){
    div = childRen[i];
    break;
    }
    }
    if(div == null)
    return (false);
    if(obj.Expanded.toLowerCase()=='true')
    {
    if(img!=null) img.innerHTML = iconCollapse;
    obj.Expanded='false';
    div.className='hide';
    }
    else
    {
    if(img!=null) img.innerHTML = iconExpand;
    obj.Expanded='true';
    div.className='shown'
    }
    }
    function MouseOver(obj)
    {
    obj.className = "clsMouseOver";
    }
    function MouseOut(obj)
    {
    if(!obj.Checked)
    obj.className = "clsLabel";
    else
    obj.className = "clsCurrentHasFocus";
    }
    /*
    function:检验checkbox中的属性
    time:
    author:zht
    */
    function check_choose(checkobj)
    {


    if (checkobj.checked==true)
    {
    checkobj.checked=false;
    }
    else
    {
    checkobj.checked=true;
    }
    }


    function MouseDown(obj)
    {
    obj.className = "clsMouseDown";
    }
    function MouseUp(obj)
    {
    MouseOut(obj);
    }
    function Click(obj)
    {
    alert(obj.outerHTML);
    //if(!obj.Checked)
    //{

    //if(CurrentNode != null)
    //{

    //CurrentNode.Checked = false;
    //MouseOut(CurrentNode);
    //}
    //obj.Checked = true;
    //CurrentNode = obj;
    //}
    //else
    //obj.Checked = false;

    //check_choose(obj.children[0])
    //MouseOut(obj);
    }
    ]]>
    </xsl:comment>
    </script>
    <style>
    <![CDATA[
    BODY
    {
    cursor:default;
    font-size:9pt;
    background-color:#F1F1F1;
    }
    span
    {
    padding:2px 3px;
    position:relative;
    display:inline;
    top:-2px;
    height:17px;
    border: solid 1px #f1f1f1;
    }
    span.clsLabel
    {

    }
    SPAN.clsSpace
    {
    font-family:verdana;
    position:relative;
    padding:3px 2px;
    top:0px;
    width:17px;
    margin:0px;
    cursor:hand;
    overflow:hidden;
    }

    span.clsSpace span
    {
    position:relative;
    width:11px;
    height:11px;
    border:solid 1px black;
    background-color:#ffffff;
    }

    SPAN.clsCollapse
    {
    line-height:6px;
    font-size:9px;
    overflow:hidden;
    padding:1px;
    }

    SPAN.clsExpand
    {
    padding-left:1px;
    overflow:hidden;
    line-height:3px;
    font-size:13px;
    padding-top:3px;
    }

    SPAN.clsLeaf
    {
    overflow:visible;
    font-size:9px;
    line-height:3px;
    padding: 1px 0px 0px 3px;
    }

    SPAN.clsMouseOver
    {
    background-color:#CCCCCC;
    border:1px solid #999999;
    }

    SPAN.clsMouseDown
    {
    background-color:#999999;
    border:1px solid #999999;
    }

    SPAN.clsCurrentHasFocus
    {
    background-color:#FFFFFF;
    border:1px solid #999999;
    }

    SPAN.clsCurrentNoFocus
    {
    background-color:#F1F1F1;
    border:1px solid #999999;
    }


    A
    {
    color:black;
    text-decoration:none;

    }

    span.clsUnavailable
    {
    height:0px;
    padding:0px;
    top:0px;
    border:none;
    color:#888888;
    }

    .hide
    {
    display:none;
    }

    .shown
    {
    display:block;
    margin-left:15px;
    }

    .deeptree IMG
    {
    position:relative;
    cursor:hand;
    top:-2px;
    margin:0px;
    padding:0px;
    }

    .treelabel
    {
    font-family:verdana;
    font-size:70.5%;
    color:white;
    }

    ]]>
    </style>
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <xsl:apply-templates select="/TreeView/Tree"/>
    </BODY>
    </HTML>

    </xsl:template>
    <xsl:template match="Tree">
    <div class="clsItem" type="parent">
    <xsl:if expr="this.hasChildNodes">
    <xsl:choose>
    <xsl:when test="@Expanded">
    <xsl:attribute name="Expanded">
    <xsl:value-of select="@Expanded"/>
    </xsl:attribute>
    </xsl:when>
    <xsl:otherwise><xsl:attribute name="Expanded">false</xsl:attribute></xsl:otherwise>
    </xsl:choose>
    </xsl:if>
    <span>
    <xsl:if expr="this.hasChildNodes">
    <xsl:attribute name="onclick">Expand(this)</xsl:attribute>
    </xsl:if>
    <xsl:attribute name="Class">clsSpace</xsl:attribute>
    <xsl:choose>
    <xsl:when expr="this.hasChildNodes">
    <xsl:choose>
    <xsl:when test="@Expanded">
    <xsl:choose>
    <xsl:when test="@Expanded[.='true']">
    <span class='clsExpand'>-</span>
    </xsl:when>
    <xsl:otherwise><span class='clsCollapse'>+</span></xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise><span class='clsCollapse'>+</span></xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise><span class='clsLeaf'>.</span></xsl:otherwise>
    </xsl:choose>
    </span>
    <span class='clsLabel' onmouseover="MouseOver(this)"  onmouseout="MouseOut(this)" onmousedown="MouseDown(this)" onmouseup="MouseUp(this)">
    <input type="checkbox" name="ck" value="{@id}" onclick="Click(this)"></input>
    <xsl:attribute name="title"><xsl:value-of select="@id" /></xsl:attribute>
    <xsl:choose>
    <xsl:when test="@URL">
    <a>
    <xsl:choose>
    <xsl:when test="@Target">
    <xsl:attribute name="target"><xsl:value-of select="@Target" /></xsl:attribute>
    </xsl:when>
    <xsl:otherwise>
    <xsl:attribute name="target">_blank</xsl:attribute>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:attribute name="Href">
    <xsl:value-of select="@URL"/>
    </xsl:attribute>
    <xsl:value-of select="@id"/>
    </a>
    </xsl:when>

    <xsl:otherwise><xsl:value-of select="@Text"/></xsl:otherwise>

    </xsl:choose>
    </span>
    <xsl:if expr="this.hasChildNodes">
    <div>
    <xsl:choose>
    <xsl:when test="@Expanded">
    <xsl:choose>
    <xsl:when test="@Expanded[.='true']">
    <xsl:attribute name="class">shown</xsl:attribute>
    </xsl:when>
    <xsl:otherwise>
    <xsl:attribute name="class">hide</xsl:attribute>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
    <xsl:attribute name="class">hide</xsl:attribute>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:choose>
    <xsl:when test="@Expanded">
    <xsl:attribute name="Expanded">
    <xsl:value-of select="@Expanded"/>
    </xsl:attribute>
    </xsl:when>
    <xsl:otherwise><xsl:attribute name="Expanded">false</xsl:attribute></xsl:otherwise>
    </xsl:choose>

    <xsl:apply-templates select="Tree"></xsl:apply-templates>

    </div>
    </xsl:if>
    </div>
    </xsl:template>
    </xsl:stylesheet>
    =============================

    我的问题是如何生成checkbox的value,如:每个树节点对应xml的node的id (0001);因为我要保存他到数据库中


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/11/24 8:52:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/7/30 0:32:43

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    62.988ms