Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: Help with 3 simple transformations?

Reply
Thread Tools

Re: Help with 3 simple transformations?

 
 
Kofi Sarfo
Guest
Posts: n/a
 
      08-13-2003
Anybody?

> There are a number of transformations I'd like to make to the XML
> below.
>
> i. For each of the available_methods/methods I'd like to grab the
> equivalent all_methods//description (based on methodid = id)
>
> ii. I'd like to determine also whether method is virtual_method or
> sealed_method
>
> iii. How about going the other way using the index (towards the end)
> to aggregate the information so that if a corresponding 'methodid'
> exists use it to build something like:
> <method type="sealed" id="4" description="Returns object stack top">
>
> <!-- CUT HERE -->
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="ListMethodsDetails.xsl"?>
> <code_sample>
> <available_methods>
> <method>
> <name>GetProperties</name>
> <methodid>1</methodid>
> </method>
> <method>
> <name>GetHash</name>
> <methodid>2</methodid>
> </method>
> <method>
> <name>GetRoot</name>
> <methodid>4</methodid>
> </method>
> </available_methods>
>
> <all_methods>
> <virtual_method>
> <id>1</id>
> <description>Returns all object properties</description>
> </virtual_method>
>
> <virtual_method>
> <id>2</id>
> <description>Returns object signature</description>
> </virtual_method>
>
> <sealed_method>
> <id>3</id>
> <description>Returns object dependencies</description>
> </virtual_method>
>
> <sealed_method>
> <id>4</id>
> <description>Returns object stack top</description>
> </virtual_method>
>
> </all_methods>
> </code_sample>


Kofi

http://www.single-blend.net/dotnet/
 
Reply With Quote
 
 
 
 
Oleg Tkachenko
Guest
Posts: n/a
 
      08-13-2003
Kofi Sarfo wrote:

>>There are a number of transformations I'd like to make to the XML
>>below.
>>
>>i. For each of the available_methods/methods I'd like to grab the
>>equivalent all_methods//description (based on methodid = id)
>>
>>ii. I'd like to determine also whether method is virtual_method or
>>sealed_method
>>
>>iii. How about going the other way using the index (towards the end)
>>to aggregate the information so that if a corresponding 'methodid'
>>exists use it to build something like:
>><method type="sealed" id="4" description="Returns object stack top">


Here it is:
<xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="methodKey" match="all_methods/*" use="id"/>
<xsl:template match="/">
<out>
<xsl:apply-templates select="/code_sample/available_methods/method"/>
</out>
</xsl:template>
<xsl:template match="method">
<method id="{methodid}" description="{key('methodKey',
methodid)/description}">
<xsl:attribute name="type">
<xsl:choose>
<xsl:when test="key('methodKey',
methodid)/self::virtual_method">virtual</xsl:when>
<xsltherwise>sealed</xsltherwise>
</xsl:choose>
</xsl:attribute>
</method>
</xsl:template>
</xsl:stylesheet>

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VB.Net / webservice requirement (but not simple for me....) Dave E ASP .Net 7 01-11-2006 02:07 PM
Simple simple program error...please help tasheeta@gmail.com C++ 14 11-02-2005 12:52 PM
Simple Question - Simple Answer? Daniel Frey XML 4 01-12-2005 04:25 PM
Re: Simple Simple question!!! Kevin Spencer ASP .Net 0 06-25-2004 05:25 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM



Advertisments