Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT - Help!

Reply
Thread Tools

XSLT - Help!

 
 
Pete
Guest
Posts: n/a
 
      07-04-2003
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:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">

<xslutput 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="ReservationNumber" />

</xsl:element>

<xsl:element name="Nights">

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

</xsl:element>

<xsl:element name="MAdults">

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

</xsl:element>

<xsl:element name="FAdults">

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

</xsl:element>

<xsl:element name="MChildren">

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

</xsl:element>

<xsl:element name="FChildren">

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

</xsl:element>

<xsl:element name="From">

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

</xsl:element>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>



Thanks in advance


 
Reply With Quote
 
 
 
 
Colin Mackenzie
Guest
Posts: n/a
 
      07-04-2003
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:
Web: http://www.elecmc.com

"Pete" <> wrote in message
news:be3nbp$ajr$1$...
> 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:stylesheet version="1.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
>
> <xslutput 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="ReservationNumber" />
>
> </xsl:element>
>
> <xsl:element name="Nights">
>
> <xsl:value-of select="NumberofDays" />
>
> </xsl:element>
>
> <xsl:element name="MAdults">
>
> <xsl:value-of select="NumberofMaleAdults" />
>
> </xsl:element>
>
> <xsl:element name="FAdults">
>
> <xsl:value-of select="NumberofFemaleAdults" />
>
> </xsl:element>
>
> <xsl:element name="MChildren">
>
> <xsl:value-of select="NumberofMaleChildren" />
>
> </xsl:element>
>
> <xsl:element name="FChildren">
>
> <xsl:value-of select="NumberofFemaleChildren" />
>
> </xsl:element>
>
> <xsl:element name="From">
>
> <xsl:value-of select="From" />
>
> </xsl:element>
>
> </xsl:for-each>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> Thanks in advance
>
>



 
Reply With Quote
 
 
 
 
Marrow
Guest
Posts: n/a
 
      07-04-2003
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:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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="ReservationNumber" />
</res>
<Nights>
<xsl:value-of select="NumberofDays" />
</Nights>
<MAdults>
<xsl:value-of select="NumberofMaleAdults" />
</MAdults>
<FAdults>
<xsl:value-of select="NumberofFemaleAdults" />
</FAdults>
<MChildren>
<xsl:value-of select="NumberofMaleChildren" />
</MChildren>
<FChildren>
<xsl:value-of select="NumberofFemaleChildren" />
</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:stylesheet 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" <> wrote in message
news:be3nbp$ajr$1$...
> 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:stylesheet version="1.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
>
> <xslutput 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="ReservationNumber" />
>
> </xsl:element>
>
> <xsl:element name="Nights">
>
> <xsl:value-of select="NumberofDays" />
>
> </xsl:element>
>
> <xsl:element name="MAdults">
>
> <xsl:value-of select="NumberofMaleAdults" />
>
> </xsl:element>
>
> <xsl:element name="FAdults">
>
> <xsl:value-of select="NumberofFemaleAdults" />
>
> </xsl:element>
>
> <xsl:element name="MChildren">
>
> <xsl:value-of select="NumberofMaleChildren" />
>
> </xsl:element>
>
> <xsl:element name="FChildren">
>
> <xsl:value-of select="NumberofFemaleChildren" />
>
> </xsl:element>
>
> <xsl:element name="From">
>
> <xsl:value-of select="From" />
>
> </xsl:element>
>
> </xsl:for-each>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> Thanks in advance
>
>



 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      07-04-2003
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:tRdNa.263$...
> 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:stylesheet version="1.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
> <xslutput 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="ReservationNumber" />
> </res>
> <Nights>
> <xsl:value-of select="NumberofDays" />
> </Nights>
> <MAdults>
> <xsl:value-of select="NumberofMaleAdults" />
> </MAdults>
> <FAdults>
> <xsl:value-of select="NumberofFemaleAdults" />
> </FAdults>
> <MChildren>
> <xsl:value-of select="NumberofMaleChildren" />
> </MChildren>
> <FChildren>
> <xsl:value-of select="NumberofFemaleChildren" />
> </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:stylesheet 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" <> wrote in message
> news:be3nbp$ajr$1$...
> > 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:stylesheet version="1.0"
> > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> >
> > <xslutput 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="ReservationNumber" />
> >
> > </xsl:element>
> >
> > <xsl:element name="Nights">
> >
> > <xsl:value-of select="NumberofDays" />
> >
> > </xsl:element>
> >
> > <xsl:element name="MAdults">
> >
> > <xsl:value-of select="NumberofMaleAdults" />
> >
> > </xsl:element>
> >
> > <xsl:element name="FAdults">
> >
> > <xsl:value-of select="NumberofFemaleAdults" />
> >
> > </xsl:element>
> >
> > <xsl:element name="MChildren">
> >
> > <xsl:value-of select="NumberofMaleChildren" />
> >
> > </xsl:element>
> >
> > <xsl:element name="FChildren">
> >
> > <xsl:value-of select="NumberofFemaleChildren" />
> >
> > </xsl:element>
> >
> > <xsl:element name="From">
> >
> > <xsl:value-of select="From" />
> >
> > </xsl:element>
> >
> > </xsl:for-each>
> >
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> >
> > Thanks in advance
> >
> >

>
>



 
Reply With Quote
 
Marrow
Guest
Posts: n/a
 
      07-04-2003
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" <> wrote in message
news:be3rt2$l6v$1$...
> 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:tRdNa.263$...
> > 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:stylesheet version="1.0"
> > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > <xslutput 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="ReservationNumber" />
> > </res>
> > <Nights>
> > <xsl:value-of select="NumberofDays" />
> > </Nights>
> > <MAdults>
> > <xsl:value-of select="NumberofMaleAdults" />
> > </MAdults>
> > <FAdults>
> > <xsl:value-of select="NumberofFemaleAdults" />
> > </FAdults>
> > <MChildren>
> > <xsl:value-of select="NumberofMaleChildren" />
> > </MChildren>
> > <FChildren>
> > <xsl:value-of select="NumberofFemaleChildren" />
> > </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:stylesheet 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" <> wrote in message
> > news:be3nbp$ajr$1$...
> > > 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:stylesheet version="1.0"
> > > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > >
> > > <xslutput 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="ReservationNumber" />
> > >
> > > </xsl:element>
> > >
> > > <xsl:element name="Nights">
> > >
> > > <xsl:value-of select="NumberofDays" />
> > >
> > > </xsl:element>
> > >
> > > <xsl:element name="MAdults">
> > >
> > > <xsl:value-of select="NumberofMaleAdults" />
> > >
> > > </xsl:element>
> > >
> > > <xsl:element name="FAdults">
> > >
> > > <xsl:value-of select="NumberofFemaleAdults" />
> > >
> > > </xsl:element>
> > >
> > > <xsl:element name="MChildren">
> > >
> > > <xsl:value-of select="NumberofMaleChildren" />
> > >
> > > </xsl:element>
> > >
> > > <xsl:element name="FChildren">
> > >
> > > <xsl:value-of select="NumberofFemaleChildren" />
> > >
> > > </xsl:element>
> > >
> > > <xsl:element name="From">
> > >
> > > <xsl:value-of select="From" />
> > >
> > > </xsl:element>
> > >
> > > </xsl:for-each>
> > >
> > > </xsl:template>
> > >
> > > </xsl:stylesheet>
> > >
> > >
> > >
> > > Thanks in advance
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      07-04-2003
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-comml-sql">


<segment><ReservationNumber>116290</ReservationNumber><NumberofDays>1</Numbe
rofDays><NumberofMaleAdults>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" <> wrote in message
news:be3ugs$197$1$...
> 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:YReNa.163$...
> > 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" <> wrote in message
> > news:be3rt2$l6v$1$...
> > > 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:tRdNa.263$...
> > > > 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:stylesheet version="1.0"
> > > > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > > > <xslutput 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="ReservationNumber" />
> > > > </res>
> > > > <Nights>
> > > > <xsl:value-of select="NumberofDays" />
> > > > </Nights>
> > > > <MAdults>
> > > > <xsl:value-of select="NumberofMaleAdults" />
> > > > </MAdults>
> > > > <FAdults>
> > > > <xsl:value-of select="NumberofFemaleAdults" />
> > > > </FAdults>
> > > > <MChildren>
> > > > <xsl:value-of select="NumberofMaleChildren" />
> > > > </MChildren>
> > > > <FChildren>
> > > > <xsl:value-of select="NumberofFemaleChildren" />
> > > > </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:stylesheet 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" <> wrote in message
> > > > news:be3nbp$ajr$1$...
> > > > > 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:stylesheet version="1.0"
> > > > > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > > > >
> > > > > <xslutput 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="ReservationNumber" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="Nights">
> > > > >
> > > > > <xsl:value-of select="NumberofDays" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="MAdults">
> > > > >
> > > > > <xsl:value-of select="NumberofMaleAdults" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="FAdults">
> > > > >
> > > > > <xsl:value-of select="NumberofFemaleAdults" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="MChildren">
> > > > >
> > > > > <xsl:value-of select="NumberofMaleChildren" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="FChildren">
> > > > >
> > > > > <xsl:value-of select="NumberofFemaleChildren" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="From">
> > > > >
> > > > > <xsl:value-of select="From" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > </xsl:for-each>
> > > > >
> > > > > </xsl:template>
> > > > >
> > > > > </xsl:stylesheet>
> > > > >
> > > > >
> > > > >
> > > > > Thanks in advance
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Colin Mackenzie
Guest
Posts: n/a
 
      07-04-2003
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" <> wrote in message
news:be3ugs$197$1$...
> 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:YReNa.163$...
> > 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" <> wrote in message
> > news:be3rt2$l6v$1$...
> > > 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:tRdNa.263$...
> > > > 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:stylesheet version="1.0"
> > > > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > > > <xslutput 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="ReservationNumber" />
> > > > </res>
> > > > <Nights>
> > > > <xsl:value-of select="NumberofDays" />
> > > > </Nights>
> > > > <MAdults>
> > > > <xsl:value-of select="NumberofMaleAdults" />
> > > > </MAdults>
> > > > <FAdults>
> > > > <xsl:value-of select="NumberofFemaleAdults" />
> > > > </FAdults>
> > > > <MChildren>
> > > > <xsl:value-of select="NumberofMaleChildren" />
> > > > </MChildren>
> > > > <FChildren>
> > > > <xsl:value-of select="NumberofFemaleChildren" />
> > > > </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:stylesheet 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" <> wrote in message
> > > > news:be3nbp$ajr$1$...
> > > > > 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:stylesheet version="1.0"
> > > > > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > > > >
> > > > > <xslutput 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="ReservationNumber" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="Nights">
> > > > >
> > > > > <xsl:value-of select="NumberofDays" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="MAdults">
> > > > >
> > > > > <xsl:value-of select="NumberofMaleAdults" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="FAdults">
> > > > >
> > > > > <xsl:value-of select="NumberofFemaleAdults" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="MChildren">
> > > > >
> > > > > <xsl:value-of select="NumberofMaleChildren" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="FChildren">
> > > > >
> > > > > <xsl:value-of select="NumberofFemaleChildren" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > <xsl:element name="From">
> > > > >
> > > > > <xsl:value-of select="From" />
> > > > >
> > > > > </xsl:element>
> > > > >
> > > > > </xsl:for-each>
> > > > >
> > > > > </xsl:template>
> > > > >
> > > > > </xsl:stylesheet>
> > > > >
> > > > >
> > > > >
> > > > > Thanks in advance
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57