By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,365 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,365 IT Pros & Developers. It's quick & easy.

New to XSLT and can't select even the first node... Any Help?

P: n/a
Hey, brand new to XSL and XSLT. I've downloaded an evaluation copy of XML
Spy to debug my transformation, but I can't get to frist base.

Can anyone help my get straightened out?

My XSLT is:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:for-each select="DataSet_Studio_Appt_Dates/Studio_Appt_Date_Times">
<ItWorked>YEAH</ItWorked> </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
and my abbreviated XML is:

<?xml version="1.0" encoding="utf-8"?>
<DataSet_Studio_Appt_Dates
xmlns="http://www.tempuri.org/DataSet_Studio_Appt_Dates.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.tempuri.org/DataSet_Studio_Appt_Dates.xsd
C:\ARESEA~1\GetStudioApptDates.xsd">
<RequestInfo>
<returncode>1</returncode>
<returnmsg>Success.</returnmsg>
</RequestInfo>
<Studio_Appt_Date_Times>
<bus_unit_id>2405</bus_unit_id>
<sched_date>8/5/2007 12:00:00 AM</sched_date>
<sched_day_text>Sun</sched_day_text>
<sched_time>11:00:00</sched_time>
<time_range_descr>Before Noon</time_range_descr>
</Studio_Appt_Date_Times>
<Studio_Appt_Date_Times>
<bus_unit_id>2405</bus_unit_id>
<sched_date>8/5/2007 12:00:00 AM</sched_date>
<sched_day_text>Sun</sched_day_text>
<sched_time>11:30:00</sched_time>
<time_range_descr>Before Noon</time_range_descr>
</Studio_Appt_Date_Times>
</DataSet_Studio_Appt_Dates>

Aug 3 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
JoelBrimm wrote:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Add
xmlns:da="http://www.tempuri.org/DataSet_Studio_Appt_Dates.xsd"
then use that prefix 'da' to qualify element names e.g.
<xsl:for-each select="DataSet_Studio_Appt_Dates/Studio_Appt_Date_Times">
<xsl:for-each
select="da:DataSet_Studio_Appt_Dates/da:Studio_Appt_Date_Times">

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #2

P: n/a
Thanks! I beat my head against the wall for 2 days before even thinking of
posting here and you gave me the answer in 10 minutes....

It works like a champ! Now I get to put back in my nested groups and play
with that!

"Martin Honnen" wrote:
JoelBrimm wrote:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Add
xmlns:da="http://www.tempuri.org/DataSet_Studio_Appt_Dates.xsd"
then use that prefix 'da' to qualify element names e.g.
<xsl:for-each select="DataSet_Studio_Appt_Dates/Studio_Appt_Date_Times">

<xsl:for-each
select="da:DataSet_Studio_Appt_Dates/da:Studio_Appt_Date_Times">

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #3

P: n/a
Tried to apply this to a more complex statement...

<xsl:for-each select="da:Studio_Appt_Date_Times[generate-id() =
generate-id(key('dates',da:sched_date)[1] ) ]">

but it did not like it.... Am I going overboard?

Thanks!
Joel.

"Martin Honnen" wrote:
JoelBrimm wrote:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Add
xmlns:da="http://www.tempuri.org/DataSet_Studio_Appt_Dates.xsd"
then use that prefix 'da' to qualify element names e.g.
<xsl:for-each select="DataSet_Studio_Appt_Dates/Studio_Appt_Date_Times">

<xsl:for-each
select="da:DataSet_Studio_Appt_Dates/da:Studio_Appt_Date_Times">

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #4

P: n/a
JoelBrimm wrote:
Tried to apply this to a more complex statement...

<xsl:for-each select="da:Studio_Appt_Date_Times[generate-id() =
generate-id(key('dates',da:sched_date)[1] ) ]">

but it did not like it.... Am I going overboard?
What does "did not like it" mean exactly? Do you get an error message?
Which one exactly?
Or do you not get the result you want? In that case post the input XML
and show us how you define that key.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #5

P: n/a
While debugging, When XML Spy hits that select and I step in, it pops up
"Finished Debugging" just like it did when I didn't have the namespace on the
simple select.

"Martin Honnen" wrote:
JoelBrimm wrote:
Tried to apply this to a more complex statement...

<xsl:for-each select="da:Studio_Appt_Date_Times[generate-id() =
generate-id(key('dates',da:sched_date)[1] ) ]">

but it did not like it.... Am I going overboard?

What does "did not like it" mean exactly? Do you get an error message?
Which one exactly?
Or do you not get the result you want? In that case post the input XML
and show us how you define that key.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #6

P: n/a
Actually, I figured out that if I set the dataset.Namespace = nothing before
I xmldoc.loadxml(dataset.getxml) then I don't have to worry about namespace
and all of those prefixes.... Now I just have to learn how to do grouping
correctly.

By the way - if you spot a mistake in the line below, I'd appreciate the
correction.

<xsl:for-each select="Studio_Appt_Date_Times[generate-id(.) =
generate-id(key('dates',sched_date)[1] ) ]">
Thanks for all of your help!
"Martin Honnen" wrote:
JoelBrimm wrote:
Tried to apply this to a more complex statement...

<xsl:for-each select="da:Studio_Appt_Date_Times[generate-id() =
generate-id(key('dates',da:sched_date)[1] ) ]">

but it did not like it.... Am I going overboard?

What does "did not like it" mean exactly? Do you get an error message?
Which one exactly?
Or do you not get the result you want? In that case post the input XML
and show us how you define that key.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #7

P: n/a
Found my problem with grouping....

I needed to add the line:
<xsl:key name="dates" match="Studio_Appt_Times" use="sched_date" />

Thanks again for all your help and I'll try to stop buggin' ya.

Joel.

"Martin Honnen" wrote:
JoelBrimm wrote:
Tried to apply this to a more complex statement...

<xsl:for-each select="da:Studio_Appt_Date_Times[generate-id() =
generate-id(key('dates',da:sched_date)[1] ) ]">

but it did not like it.... Am I going overboard?

What does "did not like it" mean exactly? Do you get an error message?
Which one exactly?
Or do you not get the result you want? In that case post the input XML
and show us how you define that key.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 3 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.