473,594 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT - Help!

I am just getting to grips with XML and I was wondering if you could help me
with something that no-one seems able or willing to help with..

I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...cation=Germany

To another XML file

http://www.discovertravelandtours.co...cation=Germany

As you can see the second one is not being output with the element names I
have defined in the XSLT, its just plain text.

The XSLT is given below, all I need is a bit of info on how to make it
output in the same way as the original file (plain xml).

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>

<xsl:template match = "/">

<xsl:for-each select="Booking/segment">

<xsl:element name="res">

<xsl:value-of select="Reserva tionNumber" />

</xsl:element>

<xsl:element name="Nights">

<xsl:value-of select="Numbero fDays" />

</xsl:element>

<xsl:element name="MAdults">

<xsl:value-of select="Numbero fMaleAdults" />

</xsl:element>

<xsl:element name="FAdults">

<xsl:value-of select="Numbero fFemaleAdults" />

</xsl:element>

<xsl:element name="MChildren ">

<xsl:value-of select="Numbero fMaleChildren" />

</xsl:element>

<xsl:element name="FChildren ">

<xsl:value-of select="Numbero fFemaleChildren " />

</xsl:element>

<xsl:element name="From">

<xsl:value-of select="From" />

</xsl:element>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Thanks in advance
Jul 20 '05 #1
6 2734
Hi,

from a brief look, the 1st problem is that yuor for-each uses <xsl:for-each
select="Booking/segment">

your XMl is of the structure /root/segment (there is no "Booking element)

Colin

--
Colin Mackenzie
XML Consultant
Electronic Media Consultants Ltd
17 North Wall, Cricklade, Wiltshire, SN6 6DU
Tel/Fax: +44 (0)1793 752193
Email: co***@elecmc.co m
Web: http://www.elecmc.com

"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with..

I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa
ny
To another XML file

http://www.discovertravelandtours.co...?Location=Germ
any
As you can see the second one is not being output with the element names I
have defined in the XSLT, its just plain text.

The XSLT is given below, all I need is a bit of info on how to make it
output in the same way as the original file (plain xml).

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:template match = "/">

<xsl:for-each select="Booking/segment">

<xsl:element name="res">

<xsl:value-of select="Reserva tionNumber" />

</xsl:element>

<xsl:element name="Nights">

<xsl:value-of select="Numbero fDays" />

</xsl:element>

<xsl:element name="MAdults">

<xsl:value-of select="Numbero fMaleAdults" />

</xsl:element>

<xsl:element name="FAdults">

<xsl:value-of select="Numbero fFemaleAdults" />

</xsl:element>

<xsl:element name="MChildren ">

<xsl:value-of select="Numbero fMaleChildren" />

</xsl:element>

<xsl:element name="FChildren ">

<xsl:value-of select="Numbero fFemaleChildren " />

</xsl:element>

<xsl:element name="From">

<xsl:value-of select="From" />

</xsl:element>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Thanks in advance

Jul 20 '05 #2
Hi Pete,
I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa
ny
To another XML file

http://www.discovertravelandtours.co...?Location=Germ
any

Are you sure you have that the right way round? Looks like the second XML
document is the source (that being the one that has the stylesheet
reference - which is incorrect BTW - in it and the one that has a <Booking>
root element as your XSLT code seems to be looking for).

Anyway, your stylesheet as it stands won't be producing well-formed XML
because there is no single root element.

Maybe your stylesheet should look like...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1"
indent="yes"/>
<xsl:template match = "/">
<root>
<xsl:for-each select="Booking/segment">
<segment>
<res>
<xsl:value-of select="Reserva tionNumber" />
</res>
<Nights>
<xsl:value-of select="Numbero fDays" />
</Nights>
<MAdults>
<xsl:value-of select="Numbero fMaleAdults" />
</MAdults>
<FAdults>
<xsl:value-of select="Numbero fFemaleAdults" />
</FAdults>
<MChildren>
<xsl:value-of select="Numbero fMaleChildren" />
</MChildren>
<FChildren>
<xsl:value-of select="Numbero fFemaleChildren " />
</FChildren>
<From>
<xsl:value-of select="From" />
</From>
</segment>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>

Notice that you don't need to use <xsl:element> for what you are doing -
explicit output elements will be cleaner and usually faster (depending on
the transformation engine used).

If you are transforming the other XML file then you just need to change...
<xsl:for-each select="Booking/segment">
to...
<xsl:for-each select="root/segment">
NB. In your XML the stylesheet pi looks like...
<?xml:styleshee t type="text/xsl" href="test3.xsl "?>
but it should be...
<?xml-stylesheet type="text/xsl" href="test3.xsl "?>
(notice it's a hyphen rather than a semi-colon - I know IE will accept the
first - but that's just an MS goof).

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. . I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with..

I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa
ny
To another XML file

http://www.discovertravelandtours.co...?Location=Germ
any
As you can see the second one is not being output with the element names I
have defined in the XSLT, its just plain text.

The XSLT is given below, all I need is a bit of info on how to make it
output in the same way as the original file (plain xml).

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:template match = "/">

<xsl:for-each select="Booking/segment">

<xsl:element name="res">

<xsl:value-of select="Reserva tionNumber" />

</xsl:element>

<xsl:element name="Nights">

<xsl:value-of select="Numbero fDays" />

</xsl:element>

<xsl:element name="MAdults">

<xsl:value-of select="Numbero fMaleAdults" />

</xsl:element>

<xsl:element name="FAdults">

<xsl:value-of select="Numbero fFemaleAdults" />

</xsl:element>

<xsl:element name="MChildren ">

<xsl:value-of select="Numbero fMaleChildren" />

</xsl:element>

<xsl:element name="FChildren ">

<xsl:value-of select="Numbero fFemaleChildren " />

</xsl:element>

<xsl:element name="From">

<xsl:value-of select="From" />

</xsl:element>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Thanks in advance

Jul 20 '05 #3
Thankyou for your replies,

Yes you are correct the first link i give is not the same xml doc as the
second link - the second one has the style sheet applied. I included the
first link to show the original un-transformed xml page.

I have put the changes you suggest in place marrow but as you will see from
the following link:
http://www.discovertravelandtours.co...cation=Germany

The output is still "text"
Or at least it is displaying as text, the output may very well be XML and
structured as such but i dont seem to be able to view it that way?

Any ideas?

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:tR******** *********@newsf ep2-gui.server.ntli .net...
Hi Pete,
I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa ny

To another XML file

http://www.discovertravelandtours.co...?Location=Germ any

Are you sure you have that the right way round? Looks like the second XML
document is the source (that being the one that has the stylesheet
reference - which is incorrect BTW - in it and the one that has a <Booking> root element as your XSLT code seems to be looking for).

Anyway, your stylesheet as it stands won't be producing well-formed XML
because there is no single root element.

Maybe your stylesheet should look like...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1"
indent="yes"/>
<xsl:template match = "/">
<root>
<xsl:for-each select="Booking/segment">
<segment>
<res>
<xsl:value-of select="Reserva tionNumber" />
</res>
<Nights>
<xsl:value-of select="Numbero fDays" />
</Nights>
<MAdults>
<xsl:value-of select="Numbero fMaleAdults" />
</MAdults>
<FAdults>
<xsl:value-of select="Numbero fFemaleAdults" />
</FAdults>
<MChildren>
<xsl:value-of select="Numbero fMaleChildren" />
</MChildren>
<FChildren>
<xsl:value-of select="Numbero fFemaleChildren " />
</FChildren>
<From>
<xsl:value-of select="From" />
</From>
</segment>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>

Notice that you don't need to use <xsl:element> for what you are doing -
explicit output elements will be cleaner and usually faster (depending on
the transformation engine used).

If you are transforming the other XML file then you just need to change...
<xsl:for-each select="Booking/segment">
to...
<xsl:for-each select="root/segment">
NB. In your XML the stylesheet pi looks like...
<?xml:styleshee t type="text/xsl" href="test3.xsl "?>
but it should be...
<?xml-stylesheet type="text/xsl" href="test3.xsl "?>
(notice it's a hyphen rather than a semi-colon - I know IE will accept the
first - but that's just an MS goof).

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
I am just getting to grips with XML and I was wondering if you could help
me
with something that no-one seems able or willing to help with..

I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa ny

To another XML file

http://www.discovertravelandtours.co...?Location=Germ any

As you can see the second one is not being output with the element names

I have defined in the XSLT, its just plain text.

The XSLT is given below, all I need is a bit of info on how to make it
output in the same way as the original file (plain xml).

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:output method="xml" version="1.0" encoding="iso-8859-1"

indent="yes"/>

<xsl:template match = "/">

<xsl:for-each select="Booking/segment">

<xsl:element name="res">

<xsl:value-of select="Reserva tionNumber" />

</xsl:element>

<xsl:element name="Nights">

<xsl:value-of select="Numbero fDays" />

</xsl:element>

<xsl:element name="MAdults">

<xsl:value-of select="Numbero fMaleAdults" />

</xsl:element>

<xsl:element name="FAdults">

<xsl:value-of select="Numbero fFemaleAdults" />

</xsl:element>

<xsl:element name="MChildren ">

<xsl:value-of select="Numbero fMaleChildren" />

</xsl:element>

<xsl:element name="FChildren ">

<xsl:value-of select="Numbero fFemaleChildren " />

</xsl:element>

<xsl:element name="From">

<xsl:value-of select="From" />

</xsl:element>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Thanks in advance


Jul 20 '05 #4
Hi Pete,

Ah, I see, that's an IE 'problem' - it always thinks that transformations
will produce HTML so it renders them as such (and because there are no
actual HTML tags in your output it just displays the text nodes). You get
the same problem, for example, if you try to output SVG from a
transformation.

Is IE an integral part of what you're doing? Or are you just using it to
view the transformation results - if so, try something else ;)

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
Thankyou for your replies,

Yes you are correct the first link i give is not the same xml doc as the
second link - the second one has the style sheet applied. I included the
first link to show the original un-transformed xml page.

I have put the changes you suggest in place marrow but as you will see from the following link:
http://www.discovertravelandtours.co...?Location=Germ
any
The output is still "text"
Or at least it is displaying as text, the output may very well be XML and
structured as such but i dont seem to be able to view it that way?

Any ideas?

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:tR******** *********@newsf ep2-gui.server.ntli .net...
Hi Pete,
I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa
ny

To another XML file

http://www.discovertravelandtours.co...?Location=Germ
any

Are you sure you have that the right way round? Looks like the second XML
document is the source (that being the one that has the stylesheet
reference - which is incorrect BTW - in it and the one that has a

<Booking>
root element as your XSLT code seems to be looking for).

Anyway, your stylesheet as it stands won't be producing well-formed XML
because there is no single root element.

Maybe your stylesheet should look like...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1"
indent="yes"/>
<xsl:template match = "/">
<root>
<xsl:for-each select="Booking/segment">
<segment>
<res>
<xsl:value-of select="Reserva tionNumber" />
</res>
<Nights>
<xsl:value-of select="Numbero fDays" />
</Nights>
<MAdults>
<xsl:value-of select="Numbero fMaleAdults" />
</MAdults>
<FAdults>
<xsl:value-of select="Numbero fFemaleAdults" />
</FAdults>
<MChildren>
<xsl:value-of select="Numbero fMaleChildren" />
</MChildren>
<FChildren>
<xsl:value-of select="Numbero fFemaleChildren " />
</FChildren>
<From>
<xsl:value-of select="From" />
</From>
</segment>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>

Notice that you don't need to use <xsl:element> for what you are doing -
explicit output elements will be cleaner and usually faster (depending on the transformation engine used).

If you are transforming the other XML file then you just need to change... <xsl:for-each select="Booking/segment">
to...
<xsl:for-each select="root/segment">
NB. In your XML the stylesheet pi looks like...
<?xml:styleshee t type="text/xsl" href="test3.xsl "?>
but it should be...
<?xml-stylesheet type="text/xsl" href="test3.xsl "?>
(notice it's a hyphen rather than a semi-colon - I know IE will accept the first - but that's just an MS goof).

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
I am just getting to grips with XML and I was wondering if you could help
me
with something that no-one seems able or willing to help with..

I have an XSLT file which should be transforming a straight XML file

http://www.discovertravelandtours.co...Location=Germa ny

To another XML file

http://www.discovertravelandtours.co...?Location=Germ
any

As you can see the second one is not being output with the element

names I have defined in the XSLT, its just plain text.

The XSLT is given below, all I need is a bit of info on how to make it
output in the same way as the original file (plain xml).

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:output method="xml" version="1.0" encoding="iso-8859-1"

indent="yes"/>

<xsl:template match = "/">

<xsl:for-each select="Booking/segment">

<xsl:element name="res">

<xsl:value-of select="Reserva tionNumber" />

</xsl:element>

<xsl:element name="Nights">

<xsl:value-of select="Numbero fDays" />

</xsl:element>

<xsl:element name="MAdults">

<xsl:value-of select="Numbero fMaleAdults" />

</xsl:element>

<xsl:element name="FAdults">

<xsl:value-of select="Numbero fFemaleAdults" />

</xsl:element>

<xsl:element name="MChildren ">

<xsl:value-of select="Numbero fMaleChildren" />

</xsl:element>

<xsl:element name="FChildren ">

<xsl:value-of select="Numbero fFemaleChildren " />

</xsl:element>

<xsl:element name="From">

<xsl:value-of select="From" />

</xsl:element>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Thanks in advance



Jul 20 '05 #5
Have a look at Marrow's XSLT IDE debugger (link below) or XML Spy if you are
looking for a development environment for XSLT.

Otherwise knickup a little VB program using MSXML to d othe transformation
or use one of the many commsnd line XSLT processors (e.g. SAXON)

Colin

"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
Yes i am just trying to view the results of the transformation to ensure
that my elements have the new names etc...

Do you have any suggestions of other browsers?

Netscape 7 (latest) does not view it correctly either!

Pete

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:YR******** ********@newsfe p2-win.server.ntli .net...
Hi Pete,

Ah, I see, that's an IE 'problem' - it always thinks that transformations
will produce HTML so it renders them as such (and because there are no
actual HTML tags in your output it just displays the text nodes). You get the same problem, for example, if you try to output SVG from a
transformation.

Is IE an integral part of what you're doing? Or are you just using it to view the transformation results - if so, try something else ;)

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
Thankyou for your replies,

Yes you are correct the first link i give is not the same xml doc as the second link - the second one has the style sheet applied. I included the first link to show the original un-transformed xml page.

I have put the changes you suggest in place marrow but as you will see from
the following link:

http://www.discovertravelandtours.co...?Location=Germ
any

The output is still "text"
Or at least it is displaying as text, the output may very well be XML and structured as such but i dont seem to be able to view it that way?

Any ideas?

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:tR******** *********@newsf ep2-gui.server.ntli .net...
> Hi Pete,
>
> > I have an XSLT file which should be transforming a straight XML file > >
> >
>

http://www.discovertravelandtours.co...Location=Germa
> ny
> >
> > To another XML file
> >
> >
>

http://www.discovertravelandtours.co...?Location=Germ
> any
>
> Are you sure you have that the right way round? Looks like the second XML
> document is the source (that being the one that has the stylesheet
> reference - which is incorrect BTW - in it and the one that has a
<Booking>
> root element as your XSLT code seems to be looking for).
>
> Anyway, your stylesheet as it stands won't be producing well-formed XML > because there is no single root element.
>
> Maybe your stylesheet should look like...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:styleshe et version="1.0"
> xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" version="1.0" encoding="iso-8859-1"
> indent="yes"/>
> <xsl:template match = "/">
> <root>
> <xsl:for-each select="Booking/segment">
> <segment>
> <res>
> <xsl:value-of select="Reserva tionNumber" />
> </res>
> <Nights>
> <xsl:value-of select="Numbero fDays" />
> </Nights>
> <MAdults>
> <xsl:value-of select="Numbero fMaleAdults" />
> </MAdults>
> <FAdults>
> <xsl:value-of select="Numbero fFemaleAdults" />
> </FAdults>
> <MChildren>
> <xsl:value-of select="Numbero fMaleChildren" />
> </MChildren>
> <FChildren>
> <xsl:value-of select="Numbero fFemaleChildren " />
> </FChildren>
> <From>
> <xsl:value-of select="From" />
> </From>
> </segment>
> </xsl:for-each>
> </root>
> </xsl:template>
> </xsl:stylesheet>
>
> Notice that you don't need to use <xsl:element> for what you are doing - > explicit output elements will be cleaner and usually faster
(depending
on
> the transformation engine used).
>
> If you are transforming the other XML file then you just need to

change...
> <xsl:for-each select="Booking/segment">
> to...
> <xsl:for-each select="root/segment">
>
>
> NB. In your XML the stylesheet pi looks like...
> <?xml:styleshee t type="text/xsl" href="test3.xsl "?>
> but it should be...
> <?xml-stylesheet type="text/xsl" href="test3.xsl "?>
> (notice it's a hyphen rather than a semi-colon - I know IE will
accept the
> first - but that's just an MS goof).
>
> Hope this helps
> Marrow
> http://www.marrowsoft.com - home of Xselerator (XSLT IDE and

debugger) > http://www.topxml.com/Xselerator
>
>
> "Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
> news:be******** ***********@new s.demon.co.uk.. .
> > I am just getting to grips with XML and I was wondering if you could help
> me
> > with something that no-one seems able or willing to help with..
> >
> > I have an XSLT file which should be transforming a straight XML file > >
> >
>

http://www.discovertravelandtours.co...Location=Germa
> ny
> >
> > To another XML file
> >
> >
>

http://www.discovertravelandtours.co...?Location=Germ
> any
> >
> > As you can see the second one is not being output with the element

names
I
> > have defined in the XSLT, its just plain text.
> >
> > The XSLT is given below, all I need is a bit of info on how to
make it > > output in the same way as the original file (plain xml).
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <xsl:styleshe et version="1.0"
> > xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:output method="xml" version="1.0" encoding="iso-8859-1"
> indent="yes"/>
> >
> > <xsl:template match = "/">
> >
> > <xsl:for-each select="Booking/segment">
> >
> > <xsl:element name="res">
> >
> > <xsl:value-of select="Reserva tionNumber" />
> >
> > </xsl:element>
> >
> > <xsl:element name="Nights">
> >
> > <xsl:value-of select="Numbero fDays" />
> >
> > </xsl:element>
> >
> > <xsl:element name="MAdults">
> >
> > <xsl:value-of select="Numbero fMaleAdults" />
> >
> > </xsl:element>
> >
> > <xsl:element name="FAdults">
> >
> > <xsl:value-of select="Numbero fFemaleAdults" />
> >
> > </xsl:element>
> >
> > <xsl:element name="MChildren ">
> >
> > <xsl:value-of select="Numbero fMaleChildren" />
> >
> > </xsl:element>
> >
> > <xsl:element name="FChildren ">
> >
> > <xsl:value-of select="Numbero fFemaleChildren " />
> >
> > </xsl:element>
> >
> > <xsl:element name="From">
> >
> > <xsl:value-of select="From" />
> >
> > </xsl:element>
> >
> > </xsl:for-each>
> >
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> >
> > Thanks in advance
> >
> >
>
>



Jul 20 '05 #6
If i do a view source on netscape i do get to see the elements so its not
all that bad...
But the source is just that .. the source... not transformed so im still no
wiser as to wether my transform works...

I notice that the source is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test4.xsl "?>
<Booking xmlns:sql="urn: schemas-microsoft-com:xml-sql">
<segment><Reser vationNumber>11 6290</ReservationNumb er><NumberofDay s>1</Numbe
rofDays><Number ofMaleAdults>0< ....<etc>Which is basically the untransformed
doc, aim i correct in thinking that the actual source is transmitted to the
browser in xml rather than a server parsed page?Like asp / php which sends
you the rendered result?
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
Yes i am just trying to view the results of the transformation to ensure
that my elements have the new names etc...

Do you have any suggestions of other browsers?

Netscape 7 (latest) does not view it correctly either!

Pete

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:YR******** ********@newsfe p2-win.server.ntli .net...
Hi Pete,

Ah, I see, that's an IE 'problem' - it always thinks that transformations
will produce HTML so it renders them as such (and because there are no
actual HTML tags in your output it just displays the text nodes). You get the same problem, for example, if you try to output SVG from a
transformation.

Is IE an integral part of what you're doing? Or are you just using it to view the transformation results - if so, try something else ;)

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
news:be******** ***********@new s.demon.co.uk.. .
Thankyou for your replies,

Yes you are correct the first link i give is not the same xml doc as the second link - the second one has the style sheet applied. I included the first link to show the original un-transformed xml page.

I have put the changes you suggest in place marrow but as you will see from
the following link:

http://www.discovertravelandtours.co...?Location=Germ
any

The output is still "text"
Or at least it is displaying as text, the output may very well be XML and structured as such but i dont seem to be able to view it that way?

Any ideas?

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:tR******** *********@newsf ep2-gui.server.ntli .net...
> Hi Pete,
>
> > I have an XSLT file which should be transforming a straight XML file > >
> >
>

http://www.discovertravelandtours.co...Location=Germa
> ny
> >
> > To another XML file
> >
> >
>

http://www.discovertravelandtours.co...?Location=Germ
> any
>
> Are you sure you have that the right way round? Looks like the second XML
> document is the source (that being the one that has the stylesheet
> reference - which is incorrect BTW - in it and the one that has a
<Booking>
> root element as your XSLT code seems to be looking for).
>
> Anyway, your stylesheet as it stands won't be producing well-formed XML > because there is no single root element.
>
> Maybe your stylesheet should look like...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:styleshe et version="1.0"
> xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" version="1.0" encoding="iso-8859-1"
> indent="yes"/>
> <xsl:template match = "/">
> <root>
> <xsl:for-each select="Booking/segment">
> <segment>
> <res>
> <xsl:value-of select="Reserva tionNumber" />
> </res>
> <Nights>
> <xsl:value-of select="Numbero fDays" />
> </Nights>
> <MAdults>
> <xsl:value-of select="Numbero fMaleAdults" />
> </MAdults>
> <FAdults>
> <xsl:value-of select="Numbero fFemaleAdults" />
> </FAdults>
> <MChildren>
> <xsl:value-of select="Numbero fMaleChildren" />
> </MChildren>
> <FChildren>
> <xsl:value-of select="Numbero fFemaleChildren " />
> </FChildren>
> <From>
> <xsl:value-of select="From" />
> </From>
> </segment>
> </xsl:for-each>
> </root>
> </xsl:template>
> </xsl:stylesheet>
>
> Notice that you don't need to use <xsl:element> for what you are doing - > explicit output elements will be cleaner and usually faster
(depending
on
> the transformation engine used).
>
> If you are transforming the other XML file then you just need to

change...
> <xsl:for-each select="Booking/segment">
> to...
> <xsl:for-each select="root/segment">
>
>
> NB. In your XML the stylesheet pi looks like...
> <?xml:styleshee t type="text/xsl" href="test3.xsl "?>
> but it should be...
> <?xml-stylesheet type="text/xsl" href="test3.xsl "?>
> (notice it's a hyphen rather than a semi-colon - I know IE will
accept the
> first - but that's just an MS goof).
>
> Hope this helps
> Marrow
> http://www.marrowsoft.com - home of Xselerator (XSLT IDE and

debugger) > http://www.topxml.com/Xselerator
>
>
> "Pete" <pb*******@NOSP AMdiscovertrave landtours.com> wrote in message
> news:be******** ***********@new s.demon.co.uk.. .
> > I am just getting to grips with XML and I was wondering if you could help
> me
> > with something that no-one seems able or willing to help with..
> >
> > I have an XSLT file which should be transforming a straight XML file > >
> >
>

http://www.discovertravelandtours.co...Location=Germa
> ny
> >
> > To another XML file
> >
> >
>

http://www.discovertravelandtours.co...?Location=Germ
> any
> >
> > As you can see the second one is not being output with the element

names
I
> > have defined in the XSLT, its just plain text.
> >
> > The XSLT is given below, all I need is a bit of info on how to
make it > > output in the same way as the original file (plain xml).
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <xsl:styleshe et version="1.0"
> > xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:output method="xml" version="1.0" encoding="iso-8859-1"
> indent="yes"/>
> >
> > <xsl:template match = "/">
> >
> > <xsl:for-each select="Booking/segment">
> >
> > <xsl:element name="res">
> >
> > <xsl:value-of select="Reserva tionNumber" />
> >
> > </xsl:element>
> >
> > <xsl:element name="Nights">
> >
> > <xsl:value-of select="Numbero fDays" />
> >
> > </xsl:element>
> >
> > <xsl:element name="MAdults">
> >
> > <xsl:value-of select="Numbero fMaleAdults" />
> >
> > </xsl:element>
> >
> > <xsl:element name="FAdults">
> >
> > <xsl:value-of select="Numbero fFemaleAdults" />
> >
> > </xsl:element>
> >
> > <xsl:element name="MChildren ">
> >
> > <xsl:value-of select="Numbero fMaleChildren" />
> >
> > </xsl:element>
> >
> > <xsl:element name="FChildren ">
> >
> > <xsl:value-of select="Numbero fFemaleChildren " />
> >
> > </xsl:element>
> >
> > <xsl:element name="From">
> >
> > <xsl:value-of select="From" />
> >
> > </xsl:element>
> >
> > </xsl:for-each>
> >
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> >
> > Thanks in advance
> >
> >
>
>



Jul 20 '05 #7

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

Similar topics

1
8675
by: Victor | last post by:
Hi, this might sound silly but I cannot figure out how to incorporate some XML of employees into some XML of a company to give new XML containing them all. For example, this is the company now <COMPANY> <EMPLOYEE currentEmployee="true"> <NAME>Victor</NAME>
12
3213
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation (xml->html) doen't happen! I have XSLT files for this, they work, I mean when I put the output of the app as an XML file on some server, and make it use the XSLT files to transform into HTML, it works, I get a HTML page.
5
7623
by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating business components that can be consumed by WebForms, WinForms, mobile devices, etc? Is it even fair to compare the such technologies? - How about for cases when you need to display dynamic elements on the form/grid (as compared to knowing data elements...
4
1824
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
4
2160
by: Moogy | last post by:
I'm pulling my hair out here. First, I'm new to XML, so that doesn't help, but none of this makes any sense to me. All I'm trying to do is take a simple source XML file and translate it with an XSLT to produce HTML code. The problem I have is that no matter what translation it runs through, it ALWAYS includes data that I don't match in the XSLT!! All I want to do is extract specific fields from the XML. Here's the XML source....
7
2844
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
3
1999
by: thomas.porschberg | last post by:
Hi, I want to read records from a database and export it in an arbitrary format. My idea was to feed a class with a String array fetched from the database and let this class fire SAX events as processor input. The basic class hierarchy is:
18
2061
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to look up what each feature depends on and gerenate a text file. For example, in the following file, I would like to find out feature A depends on A1 and A2 and feature B depends on B1 and B2. And write that to a text file.
15
2151
by: Jeff Uchtman | last post by:
Can I draw from 2 XML sources, the structure is exactly the same execpt for data contained into 1 xslt using math to add some structrure, and displaying others as node 1 and node 2? This data is XML from a Barracuda Spam server that has grown to 2. Here is a snip from my form draw. Imports System Imports System.IO Imports System.Net
0
7947
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7880
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8255
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8242
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6665
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5413
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.