p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: Collecting different child elements in page into a group


Message #1 by Arun Tejaswi <sim_ade2002@y...> on Thu, 6 Jun 2002 04:53:43 -0700 (PDT)
This is a multi-part message in MIME format.

------=_NextPart_000_0022_01C20E15.84BF0B10
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

I'm sorry, but I can't work out from this how the output you want is
related to the input. You're obviously familiar with the data, I'm not,
so it's far from obvious what transformation you actually want to do.
Perhaps you could simplify it: get rid of the parts of the input that
aren't relevant, get rid of the parts of the output that you know how to
generate, and explain how the remaining output is supposed to be derived
from the input.
 
Michael Kay
Software AG
home: Michael.H.Kay@n...
work: Michael.Kay@s... 

-----Original Message-----
From: Arun Tejaswi [mailto:sim_ade2002@y...] 
Sent: 06 June 2002 12:54
To: P2P_XSLT
Subject: [xslt] Collecting different child elements in page into a group



Hi All,

I am trying a tranformation from WML to an ML that is used by SIM. What
i'm basically trying to do is to collect all the display text in one
element and the links in a separate element as shown below.

<?xml version="1.0"?>
<!-- <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
 "http://www.wapforum.org/DTD/wml_1.1.xml"> -->
<?xml-stylesheet type="text/xsl" href="news1.xsl"?>
<wml>
<card cardid="Start">
<do type="accept" label="Headlines">
<go href="newsheads.wml"/>
</do>
<do type="options" label="Menu">
<go href="mainmenu.wml"/>
</do>
<p>
Irish police have arrested a former
leading member of the IRA who was
convicted in his absence in Belfast of
murdering an SAS officer.
<br/>
<a href="someurl" > New items </a>
some more text ...
</p>
</card>
</wml>

---------------------
TO
---------------------

<simml>

<select>
<ID>0 </ID>
 <item>
  <text>
   Start
  </text>
  <childID>1</childID>
 </item>
</select>

<display>
<id>1</id>
<childid>2</childid>
Irish police have arrested a former
leading member of the IRA who was
convicted in his absence in Belfast of
murdering an SAS officer.
<br/>
some more text ...
</display>

<menu>
<id>2</id>
<item><text>Headlines</text><child>3</child></item>
<item><text>Menu</text><child>4</child></item>
<item><text>New Item</text><child>5</child></item> <!-- From the <a>
</a> link -->
</menu>

</simml>

------------------------


I have succeeded in getting the text together using the XSL page below
but am at a loss as to how to get all the menu items into one child
page.

<xsl:template match="/">
<xsl:call-template name="start">
 <xsl:with-param name="cbID">0</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="start">
<xsl:param name="cbID" />
<simml>
 <xsl:apply-templates select="/wml/card">
<xsl:with-param name="cbID" ><xsl:value-of select="$cbID"/>
</xsl:with-param>
 </xsl:apply-templates>
</simml>
</xsl:template>

<xsl:template match="card">
<xsl:param name="cbID" />
<xsl:variable name="thiscardid">
  <xsl:value-of select="@cardid" />
</xsl:variable>

<select>
<ID><xsl:value-of select="$cbID" /> </ID>
 <item>
  <dtext>
   <xsl:value-of select="$thiscardid" />
  </dtext>
  <nextID><xsl:value-of select="concat('',$cbID+1)" /></nextID>
 </item>
</select>

<xsl:apply-templates select="//p">
  <xsl:with-param name="cbID" ><xsl:value-of
select="concat('',$cbID+1)"/></xsl:with-param> 
</xsl:apply-templates>
</xsl:template>


<xsl:template match="p">
<xsl:param name="cbID" />
<display>
<id><xsl:value-of select="$cbID" /> </id>
 <child><xsl:value-of select="concat('',$cbID+1)" /></childID>
 <text><xsl:value-of select="."/></text>
</display>
</xsl:template>
<xsl:apply-templates />

</xsl:stylesheet>

 

Can anybody please suggest how i can achieve this ?

Thanks in advance .

Regards,

Arun Tejaswi .M.




  _____  

Do You Yahoo!?
Sign-up
<http://rd.yahoo.com/welcome/*http://fifaworldcup.yahoo.com/fc/en/spl>
for Video Highlights of 2002 FIFA World Cup --- Change your mail options
at http://p2p.wrox.com/manager.asp or to unsubscribe send a blank email
to 




  Return to Index