[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] logical query - trying to be true if attribute value i
Hi all, I have an xml file called "Schedule.xml" with the following contents: <?xml version="1.0" encoding="iso-8859-1"?> <project-import> <scope ID="1" Name="CDI Support" /> <scope ID="2" Name="ABC" Predecessors="" /> <scope ID="3" Name="Online Viewing" Predecessors="" /> <scope ID="4" Name="PROJ4322" Notes="" Predecessors="" Unique_ID_Successors="9" /> <scope ID="5" Name="Resolve View and markup" Notes="" Predecessors="4" Unique_ID_Successors="10" /> <scope ID="6" Name="Create inport script" Notes="" Predecessors="5" /> <scope ID="7" Name="NBU" Predecessors="" /> <scope ID="8" Name="WA5422" Predecessors="" /> <scope ID="9" Name="Modifications" Predecessors="" /> <scope ID="10" Name="WA054334" Predecessors="" /> <scope ID="11" Name="ongoing development" Predecessors="" /> <scope ID="12" Name="V 3.2 Upgrade" Predecessors="" /> <scope ID="13" Name="WA043422" Predecessors="" /> <scope ID="14" Name="determine scope" Notes="" Predecessors="" Unique_ID_Successors="14" /> <scope ID="15" Name="setup test lab" Notes="" Predecessors="14" Unique_ID_Successors="17" /> <scope ID="16" Name="perform tests" Notes="" Predecessors="15" Unique_ID_Successors="18" /> <scope ID="17" Name="resolve test issues" Notes="" Predecessors="16" /> <scope ID="18" Name="re test" Notes="" Predecessors="" Unique_ID_Successors="15" /> <scope ID="19" Name="oracle upgrade" Notes="" Predecessors="18" Unique_ID_Successors="16" /> <scope ID="20" Name="gen upgrade" Notes="" Predecessors="19" Unique_ID_Successors="23" /> <scope ID="21" Name="Upgrade Close out" Notes="" Predecessors="20" /> <scope ID="22" Name="Receive client" Predecessors="" /> <scope ID="23" Name="install and test new client" Notes="" Predecessors="" Unique_ID_Successors="28" /> <scope ID="24" Name="Remedial work resulting from tests" Notes="" Predecessors="23" Unique_ID_Successors="27" /> <scope ID="25" Name="Do Install" Notes="" Predecessors="24" /> <scope ID="26" Name="Update install scripts" Notes="" Predecessors="" Unique_ID_Successors="32" /> <scope ID="27" Name="Final Preparation" Notes="" Predecessors="26" Unique_ID_Successors="31" /> <scope ID="28" Name="Go live" Notes="" Predecessors="27" /> <scope ID="29" Name="Maintenance" Predecessors="" /> <scope ID="30" Name="Task 43342" Predecessors="" /> <scope ID="31" Name="Ongoing maintenance" Predecessors="" /> </project-import> I want to convert this xml such that the ID tag becomes id, the Name tag becomes "scope_name", Notes becomes "scope_description", and Predecessors becomes "parent_id". Furthermore - and this is my problem - if the "Predecessors" attribute is "", then I want the corresponding parent_id attribute to be set to 1. The xslt template that I have written to [attempt to] do this transformation follows: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <wms> <xsl:apply-templates/> </wms> </xsl:template> <xsl:template match="scope"> <xsl:element name="scope"> <xsl:attribute name="id"><xsl:value-of select="@ID"/></xsl:attribute> <xsl:attribute name="scope_name"><xsl:value-of select="@Name"/></xsl:attribute> <xsl:attribute name="scope_description"><xsl:value-of select="@Notes"/></xsl:attribute> <xsl:attribute name="parent_id"> <xsl:choose> <xsl:when test="@Predecessors = ''">1</xsl:when> <xsl:otherwise><xsl:value-of select="@Predecessors"/></xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:element> </xsl:template> </xsl:stylesheet> However, the test that identifies the cae where @Predecessors = '' does not seem to be activating since instead of putting a 1 as the value of the parent_id tag, it leaves it as "". Can anyone see why this might be so? thanks heaps David Buddrige. 8-) __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|