[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] grouping problem
It seems that grouping always gives me trouble. Thanks in advance for
any help you can give me.
Here is a snippet of my input xml: <Root> <State_Standard state="CA" g_code="G6U5S33"> <state>California Content Standards</state> <SS>3.6 Narrative Analysis of Grade-Level-Appropriate Text: Identify and analyze features of themes conveyed through characters, actions, and images.</SS> </State_Standard> <State_Standard state="CA" g_code="G6U5S37"> <state>California Content Standards</state> <SS>3.5 Narrative Analysis of Grade-Level-Appropriate Text: Identify the speaker and recognize the difference between first- and third- person narration (e.g., autobiography compared with biography).</SS> </State_Standard> <State_Standard state="CA" g_code="G6U6S52"> <state>California Content Standards</state> <SS>3.4 Narrative Analysis of Grade-Level-Appropriate Text: Define how tone or meaning is conveyed in poetry through word choice, figurative language, sentence structure, line length, punctuation, rhythm, repetition, and rhyme.</SS> </State_Standard> <State_Standard state="CA" g_code="G6U5S33"> <state>California Content Standards</state> <SS>3.2 Narrative Analysis of Grade-Level-Appropriate Text: Analyze the effect of the qualities of the character (e.g., courage or cowardice, ambition or laziness) on the plot and the resolution of the conflict.</SS> </State_Standard> <State_Standard state="DE" g_code="G6U4S27"> <state>Delaware Content Standards</state> <SS>4.2a.4 Test and revise predictions as they read further</SS> </State_Standard> <State_Standard state="DE" g_code="G6U4S27"> <state>Delaware Content Standards</state> <SS>4.2a.3 Make reasonable predictions as they read</SS> </State_Standard> <State_Standard state="DE" g_code="G6U4S26"> <state>Delaware Content Standards</state> <SS>4.2a.1 Make strongly implied inferences about content and concrete ideas in a text and identify appropriate text support</SS> </State_Standard> </Root> I am creating multiple state files using <xsl:result-document> and <xsl:for-each-group> grouping by @state. Then I am attempting to group on the @g_code so as to group <SS> elements whose parents have the same @g_code as in this example snippet based on g_code="G6U5S33" (text removed for display purposes: <state>California Content Standards</state> G6U5S33 <SS>3.6 Narrative....</SS><SS>3.2 Narrative Analysis of....</SS> Here is my current xslt (2.0) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:for-each-group select="/Root/State_Standard" group-by="@state"> <xsl:sort select="current-grouping-key()"/> <xsl:variable name="stateName" select="current-group() [1]/@state"/> <xsl:result-document href="state_out/{$stateName}.txt"> <xsl:for-each-group select="current-group()" group-by="@g_code"> <xsl:for-each select="current-group()/SS"> <xsl:copy-of select="preceding-sibling::state"/ ><xsl:text>	</xsl:text> <xsl:value-of select="current-grouping-key()"/ ><xsl:text>	</xsl:text> <SS><xsl:value-of select="current-group/SS"/></ SS><xsl:text> </xsl:text> </xsl:for-each> </xsl:for-each-group> </xsl:result-document> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> Here is a snippet of the output CA.txt file which shows that the group-by="g_code" does not seem to work as I hoped it would: <state>California Content Standards</state> G6U5S33 <SS>3.6 Narrative Analysis of Grade-Level-Appropriate Text: Identify and analyze features of themes conveyed through characters, actions, and images.</ SS> <state>California Content Standards</state> G6U5S33 <SS>3.2 Narrative Analysis of Grade-Level-Appropriate Text: Analyze the effect of the qualities of the character (e.g., courage or cowardice, ambition or laziness) on the plot and the resolution of the conflict.</SS> Again, thanks in advance: Terry
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|