社区
XML/XSL
帖子详情
如何用XML写一按钮(Button),并赋给其一个标签?
yangj_bare
2002-07-03 10:59:36
如何用XML写一按钮(Button),并赋给其一个标签?
...全文
809
6
打赏
收藏
如何用XML写一按钮(Button),并赋给其一个标签?
如何用XML写一按钮(Button),并赋给其一个标签?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
saucer
2002-07-03
打赏
举报
回复
1.
<GUI>
<button>Click Me</button>
<content>Hello World</content>
</GUI>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<script language="javascript">
<![CDATA[
function sayHello(str)
{
alert(str);
}
]]>
</script>
</head>
<body>
<xsl:apply-templates select="GUI/button" />
</body>
</html>
</xsl:template>
<xsl:template match="button">
<input type="{name()}" value="{.}" onclick="sayHello('{/GUI/content}')" />
</xsl:template>
</xsl:stylesheet>
or
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<script language="javascript">
function sayHello()
{
alert('<xsl:value-of select="GUI/content" />');
}
</script>
</head>
<body>
<xsl:apply-templates select="GUI/button" />
</body>
</html>
</xsl:template>
<xsl:template match="button">
<input type="{name()}" value="{.}" onclick="sayHello()" />
</xsl:template>
</xsl:stylesheet>
JollyFred
2002-07-03
打赏
举报
回复
如果点击Button的内容也在XML文件里呢,也就是显示的那个"Hello"也是从XML文件中读出来的,那应该怎么写?
saucer
2002-07-03
打赏
举报
回复
you need to transform XML into html, for example
1.xml:
<?xml-stylesheet type="text/xsl" href="1.xsl" ?>
<GUI>
<button>Click Me</button>
</GUI>
1.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<script language="javascript">
<![CDATA[
function sayHello()
{
alert("Hello");
}
]]>
</script>
</head>
<body>
<xsl:apply-templates select="GUI/button" />
</body>
</html>
</xsl:template>
<xsl:template match="button">
<input type="{name()}" value="{.}" onclick="sayHello()" />
</xsl:template>
</xsl:stylesheet>
JollyFred
2002-07-03
打赏
举报
回复
再麻烦问一下,如果xml文件是下面这样的,显示多个按钮,按不同的按钮显示不同的content,我知道要用for-each,但不知道具体怎么写,谢谢!
<?xml-stylesheet type="text/xsl" href="Button.xsl" ?>
<GUI>
<buttons>
<button>
<caption>Click Me 1</caption>
<content>Hello JollyFred1</content>
</button>
<button>
<caption>Click Me 2</caption>
<content>Hello JollyFred2</content>
</button>
</buttons>
</GUI>
JollyFred
2002-07-03
打赏
举报
回复
再麻烦问一下,如果xml文件是下面这样的,显示多个按钮,按不同的按钮显示不同的content,我知道要用for-each,但不知道具体怎么写,谢谢!
<?xml-stylesheet type="text/xsl" href="Button.xsl" ?>
<GUI>
<buttons>
<button>
<caption>Click Me 1</caption>
<content>Hello JollyFred1</content>
</button>
<button>
<caption>Click Me 2</caption>
<content>Hello JollyFred2</content>
</button>
</buttons>
</GUI>
JollyFred
2002-07-03
打赏
举报
回复
谢谢指点!
Android studio利用shape实现不同样式的
button
(实现圆角的
按钮
)
本文详细介绍如何使用Android Studio中的shape资源文件创建具有不同样式(包括圆角)的
Button
按钮
,并提供了具体的
XML
配置示例。
Button
(
按钮
)与Image
Button
(图像
按钮
)
本文详细介绍Android开发中
Button
和Image
Button
的概念、属性及使用方法,涵盖
XML
与Java代码实现,并对比Jetpack Compose中的
Button
与Icon
Button
。内容包括核心属性、媒体控制示例、最佳实践与常见问题,帮助开发者构建高效、可访问的UI交互。
odoo的
button
在编辑状态不可见的class
标签
本文介绍在Odoo中如何通过
XML
编
写
使
button
在编辑模式下不可见的方法。使用oe_read_only类
标签
实现这一功能,确保
按钮
仅在非编辑模式下显示。
设置
button
按钮
边框颜色
本文介绍了如何设置
Button
的边框颜色。通过在drawable文件下创建
XML
,设置背景和边框颜色,可以自由定制
按钮
的外观。对于只需特定方向边框的情况,如仅显示下边框,也能灵活调整。
Button
按钮
本文介绍了如何在Android应用中自定义
Button
的背景颜色,设置按下与松开的不同样式,以及通过StateListDrawable实现状态切换。还讲解了如何通过Java代码监听并响应
Button
的点击事件。
XML/XSL
8,906
社区成员
22,677
社区内容
发帖
与我相关
我的任务
XML/XSL
XML/XSL相关问题讨论专区
复制链接
扫一扫
分享
社区描述
XML/XSL相关问题讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章