[xsl] Help with the xsl stylesheet to create attribute as element and group

Subject: [xsl] Help with the xsl stylesheet to create attribute as element and group
From: "Seng Kiat Lim" <limsengkiat83@xxxxxxxxxxx>
Date: Wed, 04 May 2005 09:10:52 +0000
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?

Current Thread