 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 24th, 2006, 07:47 AM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
simple XSLT question
Hi,
I have xml file like:
<tag1>
<tag11>
<strValue value="val1"/>
<strValue2 value="val1_2"/>
</tag1>
<tag12>
<strValue value="val2"/>
<strValue2 value="val2_2"/>
</tag12>
<tagAAA>
<strValue value="val3"/>
<strValue2 value="val3_2"/>
</tagAAA>
...
</tag1>
I need to form XSL file to output outer tags( tag11, tag12,tag13 ) as table names and strValue1, strValue2 as tables' headers.
I don't know what tag names are when creating XSL.
Thanks a lot, waiting for answers
|
|

January 24th, 2006, 08:49 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Do you know what output (HTML, presumably) you want to generate? If you don't, it's not worth even thinking about the XSLT code needed (never start writing any program if you don't know what you want the output to look like).
Then, if you still have problems writing the XSLT, give us some clues as to where you are having difficulty. Show us what you tried and where you got stuck. We're here to help you over your learning difficulties, not to write the code for you.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

January 24th, 2006, 09:30 AM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by mhkay
Do you know what output (HTML, presumably) you want to generate? If you don't, it's not worth even thinking about the XSLT code needed (never start writing any program if you don't know what you want the output to look like).
Then, if you still have problems writing the XSLT, give us some clues as to where you are having difficulty. Show us what you tried and where you got stuck. We're here to help you over your learning difficulties, not to write the code for you.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
I need an HTML file, where first-level tags are table names, second-level are headers for each table, and 3rd-level - are values in the table. I don't know how to get a list of tag names (not values!) inside specific tag.
|
|

January 24th, 2006, 10:24 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
You can get a list of the elements within a given element using child::* (or simply *) and you can get the name of an element using the name() function. I'm afraid I don't really know what you mean when you talk about a "second level tag" in HTML - you'll have to explain more clearly.
It's dangerous to use the term "tag" when talking about XSLT's data model, by the way. XSLT works in terms of a tree containing nodes. Tags appear in source XML only, and each element node in the tree usually corresponds to two tags, a start tag and an end tag. When people talk about the "content of a tag" it's not clear whether they mean the name of the element or the content of the element.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

January 24th, 2006, 10:41 AM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by mhkay
You can get a list of the elements within a given element using child::* (or simply *) and you can get the name of an element using the name() function. I'm afraid I don't really know what you mean when you talk about a "second level tag" in HTML - you'll have to explain more clearly.
It's dangerous to use the term "tag" when talking about XSLT's data model, by the way. XSLT works in terms of a tree containing nodes. Tags appear in source XML only, and each element node in the tree usually corresponds to two tags, a start tag and an end tag. When people talk about the "content of a tag" it's not clear whether they mean the name of the element or the content of the element.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
Thanks. Using <xsl:for-each select="node_my/*"> actually solved my problem. in combination with <xsl:value-of select="name(.)"/> I've got what I wanted.
Thanks again.
|
|
 |