[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stupid XSLT tricks


xpath select first instance
Robert,

This helps tremendously - this was what I was missing - in terms of the 
inner workings of selection loops.

Will try this all and report back soon.

Thanks, DW

Robert Koberg wrote:

> David RR Webber (XML eBusiness) wrote:
>
>> OK - I have managed to code myself into a corner with XSLT and 
>> looping thru a structure.
>>
>> I have one that works - and one that does not.  Trying to figure the 
>> differences between same
>> and going gently crazy!
>>
>> What I'm trying to do is just loop thru a XML instance dumping out 
>> the attributes of all nodes.
>> Right now what I have dumps out the first instance of an attribute it 
>> finds then stops!
>>
>> Of course the original template happily dumps out all elements - but 
>> - I did change the target
>> statements - and now....this has to be obvious but....
>
>
>
> The source XML would help, but you probably want something like:
>
> <xsl:template match="*">
>   <tr>
>     <td colspan="2">
>       <xsl:value-of select="local-name()"/>
> <!-- you probably want to apply-templates on ancestor-or-self to get 
> the XPath to element -->
>     </
>   </tr>
>   <xsl:apply-templates select="@*"/>
> </
>
>
> <xsl:template match="@*">
>   <tr>
>     <td>
>       <xsl:value-of select="local-name()"/>
> <!-- you probably want to apply-templates on ancestor-or-self to get 
> the XPath to element -->
>     </td>
>     <td>
>       <xsl:value-of select="."/>
>     </td>
>   </tr>
> </
>
> best,
> -Rob
>
>
>>
>> Help!
>>
>> Thanks, DW
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet version="1.0" 
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:t="http://www.testing.org/xslt">
>>
>>    <xsl:template match="/">
>>        <html>
>>            <head>
>>               <title>Get Attributes</title>
>>            </head>
>>            <body>
>>
>> <table border="0" width="100%">
>>                    <tr>
>>                        <td>
>>                                <b>
>>                                    Catalogue Attributes
>>                                </b>
>>                        </td>
>>                        <td>
>>
>>                        </td>
>>
>>                    </tr>
>>                </table>
>>
>>                <br/>
>> <table border="0" width="100%">
>>                    <tr bgcolor='yellow'><b>
>>    <th height='35'><b><font face="arial">Attribute</font></b></th>
>>    <th height='35'><b><font face="arial">Value</font></b></th>
>>  </b>
>>                    </tr>
>>
>>                    <!-- Now write the table rows out just here -->
>>                    <xsl:apply-templates/>
>>  <!-- Now write the table last row at end -->
>>                    <tr bgcolor='yellow'><b>
>>     <th WIDTH="25%" height='35'></th>
>>     <th WIDTH="75%" height='35'></th>
>>                        </b>
>>                    </tr>
>>
>>                </table>
>>            </body>
>>        </html>
>>
>>    </xsl:template>
>>
>>   <xsl:template match="*">
>>                     <tr>
>>                           <td>  <font SIZE="2">
>>                                    <xsl:value-of 
>> select="count(//*)"/> </font>
>>                            </td>
>>                           <td>  <font SIZE="2">
>>                                    <xsl:value-of select=".//@*"/> 
>> </font>
>>                            </td>
>>                    </tr>
>>   </xsl:template>
>>
>> </xsl:stylesheet>
>>
>>
>>
>> -----------------------------------------------------------------
>> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
>> initiative of OASIS <http://www.oasis-open.org>
>>
>> The list archives are at http://lists.xml.org/archives/xml-dev/
>>
>> To subscribe or unsubscribe from this list use the subscription
>> manager: <http://www.oasis-open.org/mlmanage/index.php>
>>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
>
>
>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.