Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing xml data with xslt

Status
Not open for further replies.

divinyl

IS-IT--Management
Joined
Nov 2, 2001
Messages
163
Location
GB
Hi all,

I'm a beginner with XML/XSLT. I'm supporting an application that grabs data out of a database (backend of an application) and imports it into a .net web app using xml/xslt. Part of the xslt script grabs content from columns in the database - the data is in english. I would like the xslt to transform these into the norwegian equivalents (this can be hard coded as the value in the column will only ever be yes or no - so ja/nei).

Here's an example of the part of the xslt script that picks up the column names in the database (look at the field list - the custom(norway) column):

<xsl:variable name="RegisterInfo">
<LAYOUT_INFO>
<TITLE>Project Summary Analysis - Norway</TITLE>
<DESCRIPTION>Project Summary Analysis</DESCRIPTION>
<FIELDLIST>tm_project.ROI, tm_project.cost, tm_project.summary, tm_project.actissuedate, CUSTOM(Norway)=CUSTOM_Norway, CUSTOM(Travel Required)=CUSTOM_Travel </FIELDLIST>
<DATATYPE>2</DATATYPE>
</LAYOUT_INFO>
</xsl:variable>

How do i access the actual data pulled up from the database, so for every yes value in custom(norway) column, it outputs it as "ja" and no as "nei"??

As you can probably tell i'm a COMPLETE beginner, but please point me in teh right direction if you can. Thanks.

Divinyl
 
I can not answer this in one reply, so I will try and explain as much as I can.

I will just go over the basics for a second, so bear with me.

Script graps data from the DB and creates an XML document (DOM).
Script grabs XSL and merges it will XML to create an output (There can be many, like HTML, XML, XSL.....)

Within XSL you locate data using X-Path. Like a query. You also use X-Path for different things like IF statements.

So what you have to do is find the data that is to be displayed and do an If statment on it. Here is an example of one that I have used on one of our projects.

Code:
<xsl:if test="./YesNoAnswer!='YES'">
     Display NO
</xsl:if>
<xsl:if test="./YesNoAnswer='YES'">
     Display YES
</xsl:if>

Let me know how you go.



AGIMA - professional web hosting is our business.

AGIMA Computing
 
Thank you very mcuh for your clear response! I haven't tried this yet, but will do and will let you know how i get on.

I appreciate your help

Divinyl
 
hello there,

I hope it's not too late but it looks like im gonna need some more help. I understand your response logically, having used if statements in vb, t-sql etc. However, I just cannot figure out WHERE in my XSLT file i need to place the code you posted above. Would it be within the table row section at the end, where values are retrieved from the XML file? So, for example, normally without language translation is is:

<tr>
<td>
<xsl:value-of select="TM_Project.Response"/>
</td>

So is this where i would place the if statement? Do i still need the <xsl: value-of> tag? And in the if statement, is this something like this valid: <xsl:if test="/Custom_Field/Value="yes"> process results</xsl:if> (where custom_field is a node in the xml file and Value is a sub node?

If you need it, I can post my whole xslt file.

HELP!

Divinyl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top