|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
help for xslt
hi,
i would like to create a xslt document which permit to display datas but with a selection through a drop down list. my xml file is quite simple, it looks like this: <a> <b> <c>name</c> <d>details</d> <d>details2</d> </b> <b>...</b> </a> i would like to put all the names in a drop down list and after selection display all the details. if someone can help me or tell me where i can find examples, he is welcome. i guess it's not too complicated for a specialist but i'm a beginner. thank you bye |
|
#2
|
|||
|
|||
|
There is no such thing as an XSLT document. What I suspect is
that you want to take your XML file and construct an XHTML file from that XML file using XSLT. For a basic understanding of the process, have a look at: www.w3schools.com/xsl/xsl_transformation.asp - Finnbarr |
|
#3
|
|||
|
|||
|
re
yes
you're right that's exactly what i want to do. i have already had a look to the documentation you talked about, but my problem concerns patterns in the xpath expression and the xsl:for-each and xsl:value-of. I don't know how to include the selection by drop-down list |
|
#4
|
|||
|
|||
|
Try this:
<select name="cmbName"> <xsl:for-each select="a/b/child::node()"> <option value="value"><xsl:value-of select="." /></option> </xsl:for-each> </select> |
|
#5
|
|||
|
|||
|
Try this:
<select name="cmbName"> <xsl:for-each select="a/b/child::node()"> <option value="value"><xsl:value-of select="." /></option> </xsl:for-each> </select> |
|
#6
|
|||
|
|||
|
it doesn't work, it doesn't like the double :, what does mean this expression "child::node()"? and in your program, i don't explain what i want to display in the drop down and after selection??
|
|
#7
|
|||
|
|||
|
child::node() selects all the children of the current (context)
node. Here is a simple working example of how to create the dropdown list for the names. Assuming the following XML file: <a> <b> <c>name1</c> <d>details10</d> <d>details11</d> </b> <b> <c>name2</c> <d>details20</d> <d>details21</d> </b> <b> <c>name3</c> <d>details30</d> <d>details31</d> </b> <b> <c>name4</c> <d>details40</d> <d>details41</d> </b> </a> The following code snippet: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" standalone="yes" omit-xml-declaration="no" encoding="UTF-8"/> <xsl:template match="/"> <html> <body> <select name="cmbName"> <xsl:for-each select="a/b/c"> <option value="value"><xsl:value-of select="."/></option> </xsl:for-each> </select> </body> </html> </xsl:template> </xsl:stylesheet> produces <html> <body> <select name="cmbName"> <option value="value">name1</option> <option value="value">name2</option> <option value="value">name3</option> <option value="value">name4</option> </select> </body> </html> |
|
#8
|
|||
|
|||
|
ah ok i understand, thank you.
sorry but how do you do then to display the details <d> after selection of a name in the drop down? how do you use the value selected in the drop down? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > help for xslt |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|