xsl-list
[Top] [All Lists]

XSL newbie help needed

2004-09-16 06:35:07
Below is an .xsd document.  I want to display all @type that is a model
of a car.  For example I want the output to be:

Ford Focus Mustang F150 Taurus
 
<xsd:schema>
<xsd:element name="ford" type="Ford" substitutionGroup="car"/>
<xsd:element name="focus" type="Focus" substitutionGroup="ford"/>
<xsd:element name="mustang" type="Mustang" substitutionGroup="ford"/>
<xsd:element name="f150" type="F150" substitutionGroup="ford"/>
<xsd:element name="taurus" type="Taurus" substitutionGroup="ford"/>
<xsd:element name="firestone" type="Firestone"
substitutionGroup="tires"/>
<xsd:schema>
  
 
Here is an XSL stylesheet that does what I want but I need the 2nd "if"
to be a variable that is the NAME where substitutionGroup="car".  It
can't be hard coded because I need the same XSL to transform additional
XSDs.
 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:mdc="http://us.mil.dcgs/metadata";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";> 
<xsl:template match="/">
<xsl:for-each select="descendant::xsd:element">
<xsl:if test="contains(@substitutionGroup,'car')">
<xsl:value-of select="@type"/><xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="contains(@substitutionGroup,'ford')">     <!-- ford should
not be hard coded -->
<xsl:value-of select="@substitutionGroup"/>-<xsl:value-of
select="@type"/> <xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


------------------------------------
Raytheon
Ashley Mort
Software Engineer 1
Ashley_C_Mort(_at_)raytheon(_dot_)com
300 Science Park Rd
State College, PA 16803
tel: 814 278 3920
------------------------------------




<Prev in Thread] Current Thread [Next in Thread>
  • XSL newbie help needed, Ashley Mort <=