[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL QUERY

Subject: RE: XSL QUERY
From: "Beck, Brad" <Brad.Beck@xxxxxxxxxxxxx>
Date: Fri, 7 Dec 2001 10:26:04 -0600
xsl query name
The following is one possible solution:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/Books">
    <books>
      <xsl:apply-templates select="Author"/>
    </books>
  </xsl:template>

  <xsl:template match="Author">
    <xsl:variable name="auth" select="@name"/>
    <xsl:variable name="spec" select="@Specialist"/>
    <author name="{$auth}" specialist="{$spec}">
      <xsl:apply-templates select="../BookName[contains(@name,$auth) and
@Type = $spec]"/>
    </author>
  </xsl:template>

  <xsl:template match="BookName">
    <bookname name="{@name}" type="{@Type}">

    </bookname>
  </xsl:template>
</xsl:stylesheet>

This generates the following output:

<?xml version="1.0" encoding="utf-8"?>
<books>
   <author name="Author1" specialist="Fiction">
      <bookname name="Author1Book1" type="Fiction"/>
      <bookname name="Author1Book4" type="Fiction"/>
   </author>
   <author name="Author2" specialist="General">
      <bookname name="Author2Book4" type="General"/>
   </author>
</books>

> -----Original Message-----
> From: Tarun Saheja [mailto:tarun.saheja@xxxxxxxxx] 
> Sent: Friday, December 07, 2001 9:36 AM
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSL QUERY
> Importance: High
> 
> 
> Hi
> 
> I have an XML Structure  that looks something like this:
> 
> <Books>
> 	<Author name="Author1" Specialist="Fiction" />
> 	<BookName name="Author1Book1" Type="Fiction" />
> 	<BookName name="Author1Book2" Type="General"/>
> 	<BookName name="Author1Book3" Type="Biography"/>
> 	<BookName name="Author1Book4" Type="Fiction"/>
> 	<Author name="Author2" Specialist="General" />
> 	<BookName name="Author2Book1" Type="Fiction"/>
> 	<BookName name="Author2Book2" Type="Fiction"/>
> 	<BookName name="Author2Book3" Type="Biography"/>
> 	<BookName name="Author2Book4" Type="General"/>
> </Books>
> 
> Now if I have to display the XSL by categorizing from the 
> 'Type' attribute of <BookName>, for example I want to display 
> all the books that belong to the 'Fiction' Category of 
> Author1, inspite of Author1 having other types of books, then 
> how will I achieve it?
> 
> Thanks
> Tarun.
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.