Subject: RE: [xsl] atrtributes From: Jody Robert Ford <jody.r.ford@xxxxxxxxx> Date: Wed, 1 Mar 2006 07:07:20 -0500 |
Hey, I did figure out how to ignore heterogeneous. But, I'm also trying to group the information hierarchically. <TOSET> <HETROGENEOUS>true</HETROGENEOUS> <TO CLASS="Sub Unit View"> <A N="Echelon" V="RGT"/> <A N="Seq Num" V="1"/> <A N="Assoc Unit Id" V="C1"/> <A N="Assoc Unit Name" V="Charlie"/> <A N="Assoc Unit SK" V="88"/> <A N="Unit Id" V="A2"/> <A N="Unit Name" V="Apple"/> <A N="Unit Num" V="011"/> <A N="Unit SK" V="844"/> </TO> <TO CLASS="Sub Unit View"> <A N="Echelon" V="BDE"/> <A N="Seq Num" V="1"/> <A N="Assoc Unit Id" V="02"/> <A N="Assoc Unit Name" V="Baker"/> <A N="Assoc Unit SK" V="02"/> <A N="Unit Id" V="C1"/> <A N="Unit Name" V="Charlie"/> <A N="Unit Num" V="06"/> <A N="Unit SK" V="88"/> </TO> <TO CLASS="Sub Unit View"> <A N="Echelon" V="RGT"/> <A N="Seq Num" V="1"/> <A N="Assoc Unit Id" V="C1"/> <A N="Assoc Unit Name" V="Charlie"/> <A N="Assoc Unit SK" V="88"/> <A N="Unit Id" V="A1"/> <A N="Unit Name" V="Alpha"/> <A N="Unit Num" V="01"/> <A N="Unit SK" V="84"/> </TO> <TO CLASS="Sub Unit View"> <A N="Echelon" V="BN"/> <A N="Seq Num" V="20"/> <A N="Assoc Unit Id" V="A1"/> <A N="Assoc Unit Name" V="Alpha"/> <A N="Assoc Unit SK" V="84"/> <A N="Unit Id" V="B1"/> <A N="Unit Name" V="Beta"/> <A N="Unit Num" V="01"/> <A N="Unit SK" V="8"/> </TO> <TO CLASS="Sub Unit View"> <A N="Echelon" V="BN"/> <A N="Seq Num" V="21"/> <A N="Assoc Unit Id" V="A1"/> <A N="Assoc Unit Name" V="Alpha"/> <A N="Assoc Unit SK" V="84"/> <A N="Unit Id" V="B2"/> <A N="Unit Name" V="Betty"/> <A N="Unit Num" V="11"/> <A N="Unit SK" V="81"/> </TO> </TOSET> using <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="parent" match="A" use="A[@N='Assoc Unit SK']/@V"/> <xsl:key name="id" match="A" use="A[@N='Assoc SK']/@V"/> <xsl:template match="HETROGENEOUS"></xsl:template> <xsl:template match="/"> <tr> <xsl:apply-templates select="key('parent', 'id')"/> </tr> </xsl:template> <xsl:template match="TO"> <td> <xsl:value-of select="A[@N='Unit SK']/@V"/> </td> <td> <xsl:value-of select="A[@N='Unit Name']/@V"/> </td> <xsl:apply-templates select="key('parent', 'id')"/> </xsl:template> </xsl:stylesheet> that produces <table> <tr><td>88</td><td>Charlie</td></tr> <tr><td>84</td><td>Alpha</td></tr> <tr><td>8</td><td>Beta</td></tr> <tr><td>81</td><td>Betty</td></tr> <tr><td>844</td><td>Apple</td></tr> </table> Thank you for any help. -----Original Message----- From: Jay Bryant [mailto:jay@xxxxxxxxxxxx] Sent: Tuesday, February 28, 2006 11:25 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] atrtributes Sure. And in a couple different ways. One way is to apply only certain templates. Consider the following stylesheet fragment: <xsl:template match="TOSET"> <xsl:apply-templates select="TO"/> </xsl:template> <xsl:template match="TO"> <!-- Do some stuff here --> </xsl:template> Because the TOSET template applies only the TO template, the HETROGENEOUS element never gets matched and is thus "ignored". (We'd generally say the HETROGENEOUS node is not processed.) The other way is to apply templates to everything and specifically not process certain nodes, thus: <xsl:template match="TOSET"> <xsl:apply-templates/> </xsl:template> <xsl:template match="TO"> <!-- Do some stuff here --> </xsl:template> <xsl:template match="HETROGENEOUS "/> Which one you should use depends on what you are doing and is also a matter of personal style. HTH Jay Bryant Bryant Communication Services ----- Original Message ----- From: "Jody Robert Ford" <jody.r.ford@xxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, February 28, 2006 6:55 PM Subject: RE: [xsl] atrtributes Can I have the style sheet ignore <HETROGENEOUS>true</HETROGENEOUS>? Thanks for your help. ---- <HETROGENEOUS>true</HETROGENEOUS> <xsl:template match="TO"> <xsl:value-of select="A[@N='Assoc Unit Id']/@V"/> <xsl:text>	</xsl:text> <xsl:value-of select="A[@N='Assoc Unit Name']/@V"/> <xsl:text> </xsl:text> </xsl:template> --- -----Original Message----- From: Florent Georges [mailto:darkman_spam@xxxxxxxx] Sent: Tuesday, February 28, 2006 7:15 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] atrtributes Jody Robert Ford wrote: > Can anyone explain how to access attributes in an xsl/xslt? > Where do I start my research? In any good XSLT tutorial? > How would you display a list like this: > 02 Baker > C1 Charlie > A1 Alpha > A2 Annie <xsl:template match="TO"> <xsl:value-of select="A[@N='Assoc Unit Id']/@V"/> <xsl:text>	</xsl:text> <xsl:value-of select="A[@N='Assoc Unit Name']/@V"/> <xsl:text> </xsl:text> </xsl:template> --drkm ___________________________________________________________________________ Nouveau : tiliphonez moins cher avec Yahoo! Messenger ! Dicouvez les tarifs exceptionnels pour appeler la France et l'international. Tilichargez sur http://fr.messenger.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] atrtributes, Michael Kay | Thread | Re: [xsl] atrtributes, Jay Bryant |
RE: [xsl] atrtributes, Michael Kay | Date | [xsl] XHTML to Cals table conversio, Huditsch, Roman \(LN |
Month |