테이블의 요소를 클릭하여 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과 나이를 만들었습니다. Name은 String TheName과 String Description로 구성됩니다. 나이는 긍정적 인 정수입니다. 지금은 단지 두 개의 서로 다른 사람들을 선택하는 XML 파일을 만든 :
XML :
<?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>
내 변화는 지금이 시대의 함수에서 사람의 이름으로 테이블을 만드는 것입니다 :
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
(나는 결코 자바 스크립트를 사용하지 않았다) – John