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

Re: Help with the xsl stylesheet to create attribute a

Subject: Re: Help with the xsl stylesheet to create attribute as element and group
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Wed, 4 May 2005 03:46:14 -0700 (PDT)
xsl create attribute
Please try this XSL..

(I think this is not a efficient algorithm. You may
use Muenchian grouping if you need better
performance..)

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
 
<xsl:output method="xml" indent="yes" /> 

<xsl:template match="/">
 <Unit xmlns="http://www.xml.com/xml/unit"
        
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        
xsi:schemaLocation="http://www.xml.com/xml/unit/unit.xsd">
     <Objectives>
       <xsl:for-each select="//*[local-name() =
'Objective'][not(@domain =
preceding-sibling::*[local-name() =
'Objective']/@domain)]">  
          <xsl:variable name="temp" select="@domain"
/>
          <xsl:element name="{@domain}">
            <xsl:for-each select="//*[local-name() =
'Objective'][@domain = $temp]">
              <xsl:copy>
                <xsl:value-of select="." />
              </xsl:copy>
            </xsl:for-each>
          </xsl:element>
       </xsl:for-each>
     </Objectives>
  </Unit>
</xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul

--- Seng Kiat Lim <limsengkiat83@xxxxxxxxxxx> wrote:

> I wish to produce a xml output from unitplanning xml
> document using an xsl 
> stylesheet. I am new to it so has no idea how to
> group the domain and the 
> objective under the domain.
> 
> unitPlanning.xml
> <Unit xmlns="http://www.xml.com/xml/unit"
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.xml.com/xml/unit
> unit.xsd">
> <Objectives>
> <Objective domain="CognitiveDomainObjective">an
> understanding of the roles 
> of XML in providing IT solutions to
> organization</Objective>
> <Objective domain="CognitiveDomainObjective">the
> knowledge of XML 
> technologies components and their roles in providing
> XML solution to IT and 
> business problems</Objective>
> <Objective domain="CognitiveDomainObjective">the
> knowledge of the specific 
> issues and requirements related to the field of XML
> technologies,in 
> particular XML document, DTD, XML Schema, XPath and
> XSLT</Objective>
> <Objective domain="CognitiveDomainObjective">an
> understanding of the 
> different issues related to storing and retrieving
> textual data</Objective>
> <Objective domain="CognitiveDomainObjective">an
> understanding of the 
> different design and implementation issues related
> to search 
> engines</Objective>
> <Objective domain="AffectiveDomainObjective">an
> appreciation of the role of 
> XML technologies as a solution to some of the
> distributed computing,WWW and 
> database problems</Objective>
> <Objective domain="AffectiveDomainObjective">an
> acceptance that XML 
> technology has its own limitation and it should be
> considered when 
> developing a solution</Objective>
> <Objective domain="AffectiveDomainObjective">an
> appreciation of the role of 
> DTD and XML Schema in ensuring the quality of the
> XML solution</Objective>
> <Objective domain="AffectiveDomainObjective">an
> appreciation of the 
> complexity inherent by text retrieval
> systems</Objective>
> <Objective
> domain="PsychomotorDomainObjective">designing and
> creating a 
> well-formed and valid XML document</Objective>
> <Objective
> domain="PsychomotorDomainObjective">retrieving and
> transforming 
> XML document into a number of different presentation
> format</Objective>
> <Objective
> domain="PsychomotorDomainObjective">identifying
> different 
> components of a text retrieval system</Objective>
> <Objective
> domain="PsychomotorDomainObjective">evaluating the
> different 
> techniques used in building a text retrieval
> systems</Objective>
> </Objectives>
> </Unit>
> 
> Xslt stylesheet:
> <xsl:element name="Objectives">
> <xsl:element
>
name="{unit:Unit/unit:Objectives/unit:Objective/@domain}">
> <xsl:element name="Objective">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:element>
> 
> </xsl:element>
> 
> 
> Expected output from unitPlanning.xml using
> stylesheet
> 
> <Unit xmlns="http://www.xml.com/xml/unit"
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.xml.com/xml/unit
> newUnit.xsd">
> <Objectives>
> <CognitiveDomainObjective>
> <Objective>...
> </Objective>
> <Objective>....
> </Objective>
> <Objective>.....
> </Objective>
> </CognitiveDomainObjective>
> <AffectiveDomainObjective>
> <Objective>...
> </Objective>
> </AffectiveDomainObjective>
> <PsychomotorDomainObjective>
> <Objective>.....
> </Objective>
> </PsychomotorDomainObjective>
> </Objectives>
> </Unit>
> 
> At the same time, I also wish to refer to a new
> schema in the stylesheet and 
> I also wish to know how to do it. I need to produce
> the XML file that looks 
> like this which could be valid in my schema.I have
> read the grouping using 
> the stylesheet but it does not seem working. So, can
> anyone there pls help 
> me out with this?
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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.