473,320 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XSL problem: deeping a flat XML file

Jim
Greetings, all
Can anyone tell me what's wrong with the following XSL snippet? I'm getting absolutely no display on the following:

<xsl:template name="tier3">
<xsl:param name = "currentID" />
<xsl:for-each select="//Row">
<xsl:if test="Reports_To=$currentID"> <-------problem line
<p class="level3">
<xsl:value-of select="Unique_ID"/>&#xA0;&#xA0;<xsl:value-of select="Preferred_Name"/>
</p>
</xsl:if>
</xsl:for-each>

I've checked for typos, traced & printed variables, and all manner of things, but for some reason, line #4 (the "if" test) comes up empty, even though the strings in each are equivalent. I've checked it with DOM browser in Firefox, and I see only a string--no tags or "pollutants".
If I say <xsl:value-of select="Reports_To=$currentID">, it says falsefalsefalsefalse...
I've been struggling with this all day, and I'm comfortable with XSL, but not fluent enough for the exotic stuff. Can anybody tell me what the syntax problem is, and how to fix it? It couldn't be a datatype issue, could it?
I'm using .NET , and I've got MSXML 4.0 and 6.0 installed (for .NET 2.0)

Much appreciated.

--Jim
Mar 17 '06 #1
7 1238

Jim wrote:
<xsl:for-each select="//Row">
<xsl:if test="Reports_To=$currentID"> <-------problem line


try this

<xsl:for-each select="//Row">
[<xsl:value-of select="Reports_To">] "<xsl:value-of
select="@Reports_To">"
<xsl:if test="Reports_To=$currentID">

It won't fix it, but you should see something helpful appearing between
the [] or the ""
I can't tell what's wrong without seeing the input XML, but chances are
that "Reports_To" just isn't the right selector. Is the structure
this?
<Row><Reports_To>the-id-value</Reports_To></Row>
As style issues, then mixed case element names are a pain to work with
and so are "//*" selectors. Use /foo/bar/bat/wibble if you have to,
rather than //wibble

Mar 17 '06 #2
Show us what the XML for the Row element looks like? I suspect you
aren't testing what you think you're testing.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 17 '06 #3
Jim
Here's the structure.
<Root>
<Row>
<Unique_ID>ID2</Unique_ID>
<Address_Book_Title>Whatever Title</Address_Book_Title>
<Full_Name>Doe, John Doe</Full_Name>
<Org>SCorpOrg>
<Org_Detail>Marketing</Org_Detail>
<Preferred_Name>Johnny Doe</Preferred_Name>
<Reports_To>ID1</Reports_To>
</Row>
<Row>
....
</Row>
</Root>

I have tried /Root/Row/Reports_To[5] and <xsl:value-of select="$currentID">
and <xsl:value-of select="/Root/Row/Reports_To"> and they all work fine.
But when I try to put them in a test situation, somehow ID1 no longer equals
ID1.

Thanks.

--Jim

"Joe Kesselman" <ke************@comcast.net> wrote in message
news:7Z******************************@comcast.com. ..
Show us what the XML for the Row element looks like? I suspect you aren't
testing what you think you're testing.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry

Mar 17 '06 #4
Are you really sure you're setting the parameter value correctly?

Here's my test driver. Running it on the document you gave us (after
fixing the typo) works just fine in Xylem...

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" media-type="image/svg"/>

<xsl:template match="/">
<xsl:call-template name="tier3">
<xsl:with-param name="currentID">ID1</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="tier3">
<xsl:param name = "currentID" />
<xsl:for-each select="//Row">
<xsl:if test="Reports_To=$currentID">
<p class="level3">
<xsl:value-of select="Unique_ID"/>&#xA0;&#xA0;<xsl:value-of
select="Preferred_Name"/>
</p>
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 18 '06 #5
BTW, note that the line
<xsl:output method="xml" indent="yes" media-type="image/svg"/>


is unnecessary for this test; it was left over from a previous experiment.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 18 '06 #6
Jim
Joe,
I found the problem: know thy data.
My info was originally in a complicated Visio org chart. When I exported
it to Excel, it flattened the heirarchy info, but used duplicate
"people"entries to maintain the heirarchy. I didn't realize the duplicate
thing was occuring. My code was fine, but I wasn't familiar enough with the
data to pick up on what was happening.
Once I realized what was going on, I added a check for the duplicate
tree thing, and presto.

Thanks for your help.

--Jim
"Joe Kesselman" <ke************@comcast.net> wrote in message
news:7r******************************@comcast.com. ..
Are you really sure you're setting the parameter value correctly?

Here's my test driver. Running it on the document you gave us (after
fixing the typo) works just fine in Xylem...

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" media-type="image/svg"/>

<xsl:template match="/">
<xsl:call-template name="tier3">
<xsl:with-param name="currentID">ID1</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="tier3">
<xsl:param name = "currentID" />
<xsl:for-each select="//Row">
<xsl:if test="Reports_To=$currentID">
<p class="level3">
<xsl:value-of select="Unique_ID"/>&#xA0;&#xA0;<xsl:value-of
select="Preferred_Name"/>
</p>
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry

Mar 19 '06 #7
Jim wrote:
I found the problem: know thy data.


Glad you found it. Been there, done that, which is why I always get a
bit suspicious when someone shows us only stylesheet or only data.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 19 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: raykyoto | last post by:
Hi all, I'm sure this is a popular question that comes up every few months here. Indeed, I've looked at some of the past postings, but I would like to ask things differently. Basically, I'm...
1
by: Tim Fierro | last post by:
Hello, I have had many years using flat file databases (File Express from way back) but am now at a company where a relational database is needed and would carry us into the future. Since I...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
4
by: Ben | last post by:
So, at my place of employment, we use a national standard to transmit data between certain applications. This standard consists of a fixed width, flat file 4500-some-odd chars wide that contain...
4
by: infiniti | last post by:
Hi, I am coming across problems in trying to EFFICIENTLY merge to XML files into one which involves transposing the rows into columns so that I can either generate a single flat xml file or store...
10
by: ircmaxell | last post by:
Ok, I have a program that reads the contents of a file (1 line, 5 '|' seperated items). Every so often (between twice a day, and 200 times a day), it rewrites the contents of that file. I also do...
9
by: FFMG | last post by:
In my site I have a config table, (MySQL), with about 30 entries; the data is loaded on every single page load. This is not the only call to the db, (we do a total of about 8 calls to the db). As...
2
by: murthydb2 | last post by:
Hi My requirement is that i have to write a stored procedure in db2 and that will be executed in a batch file . Any system error or validation error that occurs inside the db2 sp during...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.