473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

XSL Grouping/Headers Help Needed.

I'm at a total loss here, I need to create an XSL template for an XML file I have, and can't seem to figure out how to get it finished. I would appreciate any help someone can provide.

I have an xml document and the it's made up like this:

Expand|Select|Wrap|Line Numbers
  1. <Catalogue>
  2.     <ProdID>1</ProdID>
  3.     <ProdDescription>Bristol Fixture HP Sodium</ProdDescription>
  4.     <ProdPartNo>AP-0207</ProdPartNo>
  5.     <ProdTypeID>3</ProdTypeID>
  6.     <ProdTypeDescription>Ornamental</ProdTypeDescription>
  7.     <ProdCatID>2</ProdCatID>
  8.     <ProdCatDescription>Lighting Fixtures</ProdCatDescription>
  9.     <ProdSubCatID>4</ProdSubCatID>
  10.     <ProdSubCatDescription>Bristol Series Fixtures</ProdSubCatDescription>
  11.     <PDFFileName>O2-Renaissance Fixture.pdf</PDFFileName>
  12. </Catalogue>
  13.  
I need it to write out a header for each distinct ProdCatID and then under that, a header for each ProdSubCatID with the appropriate ProdPartNo listed under the sub categories.

I have gotten it to the point where I can get the first categories to list with each entry under them, but can't get the second to work.

Here's the code I have so far:

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="/">
  2.     <!-- consider all ProdCatDescription, one by one, sorted, no double -->
  3.     <xsl:for-each select="/NewDataSet/Catalogue/ProdCatDescription[not(../preceding-sibling::Catalogue/ProdCatDescription = .)]">
  4.         <xsl:sort/>
  5.         <xsl:call-template name="handle-ProdCatDescription">
  6.             <xsl:with-param name="ProdCatDescription" select="."/>
  7.         </xsl:call-template>
  8.     </xsl:for-each>
  9. </xsl:template>
  10.  
  11. <!-- display all ProdCatDescription for a give Catalogue -->
  12. <xsl:template name="handle-ProdCatDescription">
  13.     <xsl:param name="ProdCatDescription"/>
  14.     <xsl:variable name="Catalogues" select="/NewDataSet/Catalogue[ProdCatDescription = $ProdCatDescription]"/>
  15.     <H3>
  16.     <xsl:value-of select="$ProdCatDescription"/>, contains <xsl:value-of select="count($Catalogues)"/> Products.
  17.     </H3>
  18.     <xsl:for-each select="$Catalogues">
  19.         <xsl:sort select="ProdSubCatDescription"/>
  20.         <xsl:sort select="ProdPartNo"/>
  21.  
  22.         <xsl:value-of select="ProdSubCatDescription"/> :: <xsl:value-of select="ProdPartNo"/>
  23.         <br/>
  24.     </xsl:for-each>
  25. </xsl:template>
  26.  
This results in:

Expand|Select|Wrap|Line Numbers
  1. Main Category Name 1
  2.     Sub Category Name 1 :: Product Part Number
  3.     Sub Category Name 1 :: Product Part Number
  4.     Sub Category Name 2 :: Product Part Number
  5.  
  6. Main Category Name 2...etc...
I need it to look like this, if the Sub Category Names are the same...

Expand|Select|Wrap|Line Numbers
  1. Main Category Name 1
  2.     Sub Category Name 1
  3.         Product Part Number
  4.         Product Part Number
  5.     Sub Category Name 2
  6.         Product Part Number
  7.  
  8. Main Category Name 2...etc...
I need this done and am at a complete end, any help is much appreciated. Thanks a ton.
Aug 1 '06 #1
1 1352
bharathreddy
111 100+
Dont be upset, we have a tool to create schemas called styluss. Go through the link below.

http://www.stylusstudio.com/videos/x...mlschema1.html
Aug 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: thefirstwml | last post by:
I am using Visual Studio.NET 2002 Professional and am attempting to create a report on Crystal Reports for .NET. I know that Crystal Reports can group on anything, and when I add multiple...
2
by: Chris Beach | last post by:
Hi there. I'd like to be able to group together inputs on an HTML form inside, say, a <div> or <fieldset> and then use javascript to iterate through the controls in the group and disable them....
4
by: Vivek | last post by:
how to add the headers to httpwebrequest/httpwebresponse from .net code ?
1
by: teddysnips | last post by:
Having recently had excellent service here (many thanks, Erland!), here's another wee problem. SQL 2000 I need to get a report which will display the movement of people thus: ID DIRECTION ...
1
by: Brian Coy | last post by:
I am creating a database to track scrap on a daily basis at my plant. I have to provide a weekly scrap report with the amount of each part scrapped per day. I have the basic database set up, and...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
4
by: ian_gendreau | last post by:
I am writing a database for sales forecasting. All of my entries are in a table, each entry has a Projecting Booking Date. I need to write a report with 4 groupings: 0-30 Days Out 31-60 Days...
4
by: Rui.Hu719 | last post by:
Hi, All: I read the following passage from a book: "There are three exceptions to the rule that headers should not contain definitions: classes, const objects whose value is known at compile...
7
by: derekdeben | last post by:
Hi, I have created a report that totals the number of days it took a product to ship by percentage by a date range for a specific location. My data comes from a query with the following headers: ...
37
by: C_guy | last post by:
Does anyone know of a (hopefully free) tool that can traverse a project and determine which "#include"s are not needed or needed in every .C file? This would be helpful in removing header...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.