English 中文(简体)
• 如何使用XSLT,根据XML的回归数据检查无线电塔
原标题:How to check radio buttons based upon returned XML data using an XSLT

锡克尔特公司的头部在利用他们生产一种表格并填满一个表格时,先是黑白。 我已经将XSLT作了整理,能够从服务器获得XML数据。 我认为,我正确地把所有领域等同各自的XML数据。 然而,我可以研究如何根据储存的XML数据对无线电塔顿和检查箱进行检查。 我在净额上找到了两个类似的职位,但我无法正确发挥这些职位的作用,希望这里的人能够给我一手。

I have made some small test code with which to try and get this working as I didn t want to risk messing up the full form. The test XML and XSL are shown below.

XML

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test2.xsl"?>
<root>
<radiobuttons>
    <radio1>Y</radio1>
    <blurb>blahblahblah</blurb>
</radiobuttons>
</root>

XSL

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes" omit-xml-declaration="no"
            encoding="UTF-8"/>
<xsl:template match="/">
<HTML>
<BODY>
<form>
<xsl:apply-templates select="root"/>
</form>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="root">

<input type="radio" name="radio1" value="Y" >
<xsl:if test="root/radiobuttons/radio1= Y ">
<xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
</input>Radio Button 1

<input type="radio" name="radio1" value="N" >
<xsl:if test="root/radiobuttons/radio1= N ">
<xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
</input>Radio Button 2

<br/>
<input name="blurb" type="text" id="blurb" value="{./radiotbuttons/blurb}"></input>
</xsl:template>
</xsl:stylesheet>

如果XML具有储存的Y值,则像第一个无线电塔顿一样在由此产生的超文本中加以检查,如果其价值为N,则像第二个信 but一样。 如果任何人能够说明为什么不工作,或者完全是错误的做法,那么我就真的感激。

最佳回答

you have made an error in your xpath

u 必须从“root/radiobuttons/radio1”中去除,因为此时此刻,你身处深层的 no子里,真心会再 ex灭。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes" omit-xml-declaration="no"
            encoding="UTF-8"/>
<xsl:template match="/">
<HTML>
<BODY>
<form>
<xsl:apply-templates select="root"/>
</form>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="root">

<input type="radio" name="radio1" value="Y" >
<xsl:if test="radiobuttons/radio1= Y ">
<xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
</input>Radio Button 1

<input type="radio" name="radio1" value="N" >
<xsl:if test="radiobuttons/radio1= N ">
<xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
</input>Radio Button 2

<br/>
<input name="blurb" type="text" id="blurb" value="{./radiobuttons/blurb}"></input>
</xsl:template>
</xsl:stylesheet>
问题回答

暂无回答




相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签