XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 30th, 2004, 06:28 AM
poisontheused poisontheused is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 13 poisontheused User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 52 m 56 sec
Reputation Power: 0
Question XSL:if or XSL:choose help

XML file
Code:
<FormattedReportObjects>
<FormattedReportObject type="CTFormattedField" Type="string" FieldName="{VhStock.MAKE}">
<ObjectName>Field81</ObjectName>
<FormattedValue>MITSUBISHI</FormattedValue>
<Value>MITSUBISHI</Value>
</FormattedReportObject>			
<FormattedReportObject type="CTFormattedField" Type="string" FieldName="{VhStock.model_name}">
<ObjectName>Field83</ObjectName>
<FormattedValue>MAGNA</FormattedValue>
<Value>MAGNA</Value>
</FormattedReportObject>
</FormattedReportObjects>

<FormattedReportObjects>			
<FormattedReportObject type="CTFormattedField" Type="string" FieldName="{VhStock.MAKE}">
<ObjectName>Field81</ObjectName>
<FormattedValue>DAEWOO</FormattedValue>
<Value>DAEWOO</Value>
</FormattedReportObject>			
<FormattedReportObject type="CTFormattedField" Type="string" FieldName="{VhStock.model_name}">
<ObjectName>Field83</ObjectName>
<FormattedValue>LANOS</FormattedValue>
<Value>LANOS</Value>
</FormattedReportObject>
</FormattedReportObjects>


I am wanting to change my XSL stylesheet to select all the formattedreportobjects that have a <FormattedReportObject type="CTFormattedField" Type="string" FieldName="{VhStock.MAKE}"> value that = Mitsubishi.

At the moment its just outputting all the FormattedReportObjects. Any help would be appreciated.

Here is my current XSL file
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<basefont face="Verdana" size="2"/>
<body>
<h2>Used Vehicles</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="FormattedReportObjects">

<table border="0">
<xsl:apply-templates/>
</table>

</xsl:template>
<xsl:template match="FormattedReportObject">
<tr>
<xsl:apply-templates select="Value"/>
</tr>
</xsl:template>

<xsl:template match="Value">
<td bgcolor="#E1E1E1" width="200">
<xsl:if test="parent::FormattedReportObject[@FieldName = '{VhStock.MAKE}']">
<xsl:text>Make</xsl:text>
</xsl:if>
<xsl:if test="parent::FormattedReportObject[@FieldName = '{VhStock.model_name}']">
<xsl:text>Model Name</xsl:text>
</xsl:if>
</td>

<td>
<xsl:value-of select="text()"/>
</td>
</xsl:template>
</xsl:stylesheet>


Thanks for your time

Reply With Quote
  #2  
Old August 31st, 2004, 04:57 AM
IvanE IvanE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 98 IvanE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 38 sec
Reputation Power: 5
Can you check this line,

<FormattedReportObject type="CTFormattedField" Type="string" FieldName="{VhStock.MAKE}">

Can you do that? I think it may be possible to only have one value in there. Only type for example.

You can do it like this though,
<FormattedReportObject>
<type>CTFormattedField</type>
<Type>string</Type>
<FieldName>{VhStock.MAKE}</FieldName>
</FormattedReportObject>

I am not sure what you are trying with the {} value either. But to keep it simple try it with an actual value first.

Try and do it as simply as possible first, take out the last 2 templates and just do it in the first one. The templates look a bit wrong at the moment to me. I don't think you need the third one, but avoid all that at first and get it working.

Reply With Quote
  #3  
Old August 31st, 2004, 05:26 AM
poisontheused poisontheused is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 13 poisontheused User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 52 m 56 sec
Reputation Power: 0
The XML file is generated in that syntax from Crystal reports. It is a very long XML file that is going to need regular updating so rewriting the XML file is not really an easy solution unfortunately.

Its quite an awkward setup i know, and thats why it's causing me some trouble trying to get it to select certain values. I think i need to use XSL:if or XSL:choose but am unsure how to write this with my particular XML file.

Reply With Quote
  #4  
Old August 31st, 2004, 12:12 PM
IvanE IvanE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 98 IvanE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 38 sec
Reputation Power: 5
Check out this page and it might shed some light on why I brought up your xml,

http://www.w3schools.com/xml/xml_attributes.asp

As regards <xsl:if> and <xsl:choose>, well you'd use <xsl:choose> if you are looking for one value and if not that value then another one (hence <xsltherwise>). If you are only looking for one particular value then use xsl:if.

I think you need to use xsl:if something like this,

<xsl:if test="First Node">
<xsl:if test="Second Node">
<xsl:if test="Third Node">
Do something here...
</xsl:if>
</xsl:if>
</xsl:if>

This won't do anything unless you have all the nodes matching what you want. There may be a better way of doing this but for the time being, try and get a simple working xsl file first and take it from there.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL:if or XSL:choose help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT