xmlファイルのxslt変換を使用してhtmlページを変更する方法を、テーブルの要素をクリックして調べようとしています。 私は周りを見回して答えを見つけることができませんでしたが、ここでは簡単なコードです。ページを変更して何かを表示する方法を知りたいと思います: 私はそれ以外のコードを読む必要はないと思います最後のものは、XSLTです。コードの他のセクションを追加しました。変更が必要な場合もあります。xslt変換リンク
XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com">
<xs:element name="Table">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element ref="Person"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Person">
<xs:complexType>
<xs:all maxOccurs="1">
<xs:element ref="Name"/>
<xs:element minOccurs="1" ref="Age"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="Name">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" ref="theName"/>
<xs:element maxOccurs="1" ref="Description"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="theName" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
<xs:element abstract="false" name="Age" type="xs:positiveInteger"/>
</xs:schema>
だから私は二つの要素、theNameと年齢を作成しました。名前はString TheNameとString Descriptionで構成されます。年齢は正の整数です。私の変換が今そこに年齢の関数で人の名前を持つテーブルを作ることです
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="try.xsl"?>
<Table xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com try.xsd">
<Person>
<Name>
<theName>Thomas</theName>
<Description>He is a nice guy</Description>
</Name>
<Age>10</Age>
</Person>
<Person>
<Name>
<theName>Peter</theName>
<Description>He is good at swimming</Description>
</Name>
<Age>12</Age>
</Person>
</Table>
:
XML:今、私はちょうど2つの異なる人々を選択するXMLファイルを作成しましたXSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ws="http://www.w3schools.com"
version="1.0">
<xsl:template match="/">
<html>
<table border="2">
<tr bgcolor="red">
<th>Name</th>
<th>Age</th>
</tr>
<xsl:for-each select="ws:Table/ws:Person">
<tr>
<td><xsl:value-of select="ws:Name/ws:theName"/></td>
<td><xsl:value-of select="ws:Age"/></td>
</tr>
</xsl:for-each>
</table>
これは私が助けを必要とするところで、人の名前をクリックするとその人の説明をどのように表示するのですか?基本的に私がトーマスをクリックすると "彼は素敵な男"と表示されたいと思います。ピーターをクリックすると "彼はいいスイマーです"と表示したいのです。
</html>
</xsl:template>
</xsl:stylesheet>
あなたは
マウスクリックに関する情報の表示/非表示の方法について、javascript/CSSソリューションを検索しようとしましたか? – erikxiv
いいえ、xsltでは可能ではありませんか? – John
(私はJavaScriptを一度も使用していません) – John