Subject: RE: [xsl] atrtributes From: Jody Robert Ford <jody.r.ford@xxxxxxxxx> Date: Wed, 1 Mar 2006 22:52:14 -0500 |
Sorry. Source... <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> My stylesheet... <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> The desired output. <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> Thanks, jody -----Original Message----- From: Jay Bryant [mailto:jay@xxxxxxxxxxxx] Sent: Wednesday, March 01, 2006 1:37 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] atrtributes The list is fortunate to have a couple of standard references for grouping: http://www.jenitennison.com/xslt/grouping/index.xml http://www.dpawson.co.uk/xsl/sect2/N4486.html And for XSLT 2.0: http://www.dpawson.co.uk/xsl/rev2/grouping.html The bestest way to ask questions on the list is to give us sample input, the desired output, and your best attempt so far at the XSLT code. (Of course, you should trim things down to just the bits that cause trouble, as time is precious.) It makes for big posts, but we're used to it. Otherwise, folks have to guess what you want, ask a bunch of questions, or just ignore the message. So, once you grind through the information at those first two links (and the third if you can use XSLT 2.0) and have tried to implement grouping, come back to the list with your specific questions. Also, if you get it to work on your own, show us what you did. Then we can talk about optimizing, too. HTH Jay Bryant Bryant Communication Services ----- Original Message ----- From: "Jody Robert Ford" <jody.r.ford@xxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, March 01, 2006 6:07 AM Subject: RE: [xsl] atrtributes 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, Jay Bryant | Thread | [xsl] XHTML to Cals table conversio, Huditsch, Roman \(LN |
[xsl] Expression in XPath, Dariusz Borowski | Date | [xsl] Reg. Posting question, koteshwar.venigalla |
Month |