XSLT - Help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pete

    #1

    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



    To another XML file



    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


  • Colin Mackenzie

    #2
    Re: XSLT - Help!

    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: colin@elecmc.co m
    Web: http://www.elecmc.com

    "Pete" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
    news:be3nbp$ajr $1$8300dec7@new s.demon.co.uk.. .[color=blue]
    > I am just getting to grips with XML and I was wondering if you could help[/color]
    me[color=blue]
    > 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
    >
    >[/color]

    ny[color=blue]
    >
    > To another XML file
    >
    >[/color]

    any[color=blue]
    >
    > 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"[/color]
    indent="yes"/>[color=blue]
    >
    > <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
    >
    >[/color]


    Comment

    • Marrow

      #3
      Re: XSLT - Help!

      Hi Pete,
      [color=blue]
      > I have an XSLT file which should be transforming a straight XML file
      >
      >[/color]

      ny[color=blue]
      >
      > To another XML file
      >
      >[/color]

      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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
      news:be3nbp$ajr $1$8300dec7@new s.demon.co.uk.. .[color=blue]
      > I am just getting to grips with XML and I was wondering if you could help[/color]
      me[color=blue]
      > 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
      >
      >[/color]

      ny[color=blue]
      >
      > To another XML file
      >
      >[/color]

      any[color=blue]
      >
      > 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"[/color]
      indent="yes"/>[color=blue]
      >
      > <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
      >
      >[/color]


      Comment

      • Pete

        #4
        Re: XSLT - Help!

        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:


        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$ VZ4.30756@newsf ep2-gui.server.ntli .net...[color=blue]
        > Hi Pete,
        >[color=green]
        > > I have an XSLT file which should be transforming a straight XML file
        > >
        > >[/color]
        >[/color]
        http://www.discovertravelandtours.co...Location=Germa[color=blue]
        > ny[color=green]
        > >
        > > To another XML file
        > >
        > >[/color]
        >[/color]
        http://www.discovertravelandtours.co...?Location=Germ[color=blue]
        > 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[/color]
        <Booking>[color=blue]
        > 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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
        > news:be3nbp$ajr $1$8300dec7@new s.demon.co.uk.. .[color=green]
        > > I am just getting to grips with XML and I was wondering if you could[/color][/color]
        help[color=blue]
        > me[color=green]
        > > 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
        > >
        > >[/color]
        >[/color]
        http://www.discovertravelandtours.co...Location=Germa[color=blue]
        > ny[color=green]
        > >
        > > To another XML file
        > >
        > >[/color]
        >[/color]
        http://www.discovertravelandtours.co...?Location=Germ[color=blue]
        > any[color=green]
        > >
        > > As you can see the second one is not being output with the element names[/color][/color]
        I[color=blue][color=green]
        > > 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"[/color]
        > indent="yes"/>[color=green]
        > >
        > > <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
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Marrow

          #5
          Re: XSLT - Help!

          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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
          news:be3rt2$l6v $1$8302bc10@new s.demon.co.uk.. .[color=blue]
          > 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[/color]
          from[color=blue]
          > the following link:
          >[/color]

          any[color=blue]
          >
          > 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$ VZ4.30756@newsf ep2-gui.server.ntli .net...[color=green]
          > > Hi Pete,
          > >[color=darkred]
          > > > I have an XSLT file which should be transforming a straight XML file
          > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://www.discovertravelandtours.co...Location=Germa[color=blue][color=green]
          > > ny[color=darkred]
          > > >
          > > > To another XML file
          > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green]
          > > any
          > >
          > > Are you sure you have that the right way round? Looks like the second[/color][/color]
          XML[color=blue][color=green]
          > > 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[/color]
          > <Booking>[color=green]
          > > 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[/color][/color]
          on[color=blue][color=green]
          > > the transformation engine used).
          > >
          > > If you are transforming the other XML file then you just need to[/color][/color]
          change...[color=blue][color=green]
          > > <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[/color][/color]
          the[color=blue][color=green]
          > > 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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
          > > news:be3nbp$ajr $1$8300dec7@new s.demon.co.uk.. .[color=darkred]
          > > > I am just getting to grips with XML and I was wondering if you could[/color][/color]
          > help[color=green]
          > > me[color=darkred]
          > > > 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
          > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://www.discovertravelandtours.co...Location=Germa[color=blue][color=green]
          > > ny[color=darkred]
          > > >
          > > > To another XML file
          > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green]
          > > any[color=darkred]
          > > >
          > > > As you can see the second one is not being output with the element[/color][/color][/color]
          names[color=blue]
          > I[color=green][color=darkred]
          > > > 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"[/color]
          > > indent="yes"/>[color=darkred]
          > > >
          > > > <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
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Colin Mackenzie

            #6
            Re: XSLT - Help!

            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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
            news:be3ugs$197 $1$830fa7b3@new s.demon.co.uk.. .[color=blue]
            > 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$ 4O4.8790@newsfe p2-win.server.ntli .net...[color=green]
            > > Hi Pete,
            > >
            > > Ah, I see, that's an IE 'problem' - it always thinks that[/color][/color]
            transformations[color=blue][color=green]
            > > 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[/color][/color]
            get[color=blue][color=green]
            > > 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[/color][/color]
            to[color=blue][color=green]
            > > 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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
            > > news:be3rt2$l6v $1$8302bc10@new s.demon.co.uk.. .[color=darkred]
            > > > Thankyou for your replies,
            > > >
            > > > Yes you are correct the first link i give is not the same xml doc as[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > > > second link - the second one has the style sheet applied. I included[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > > > 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[/color]
            > > from[color=darkred]
            > > > the following link:
            > > >[/color]
            > >[/color]
            >[/color]
            http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green]
            > > any[color=darkred]
            > > >
            > > > The output is still "text"
            > > > Or at least it is displaying as text, the output may very well be XML[/color][/color]
            > and[color=green][color=darkred]
            > > > 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$ VZ4.30756@newsf ep2-gui.server.ntli .net...
            > > > > Hi Pete,
            > > > >
            > > > > > I have an XSLT file which should be transforming a straight XML[/color][/color][/color]
            file[color=blue][color=green][color=darkred]
            > > > > >
            > > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://www.discovertravelandtours.co...Location=Germa[color=blue][color=green][color=darkred]
            > > > > ny
            > > > > >
            > > > > > To another XML file
            > > > > >
            > > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green][color=darkred]
            > > > > any
            > > > >
            > > > > Are you sure you have that the right way round? Looks like the[/color][/color][/color]
            second[color=blue][color=green]
            > > XML[color=darkred]
            > > > > 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[/color][/color]
            > XML[color=green][color=darkred]
            > > > > 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[/color][/color]
            > doing -[color=green][color=darkred]
            > > > > explicit output elements will be cleaner and usually faster[/color][/color][/color]
            (depending[color=blue][color=green]
            > > on[color=darkred]
            > > > > the transformation engine used).
            > > > >
            > > > > If you are transforming the other XML file then you just need to[/color]
            > > change...[color=darkred]
            > > > > <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[/color][/color][/color]
            accept[color=blue][color=green]
            > > the[color=darkred]
            > > > > first - but that's just an MS goof).
            > > > >
            > > > > Hope this helps
            > > > > Marrow
            > > > > http://www.marrowsoft.com - home of Xselerator (XSLT IDE and[/color][/color][/color]
            debugger)[color=blue][color=green][color=darkred]
            > > > > http://www.topxml.com/Xselerator
            > > > >
            > > > >
            > > > > "Pete" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
            > > > > news:be3nbp$ajr $1$8300dec7@new s.demon.co.uk.. .
            > > > > > I am just getting to grips with XML and I was wondering if you[/color][/color][/color]
            could[color=blue][color=green][color=darkred]
            > > > 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[/color][/color][/color]
            file[color=blue][color=green][color=darkred]
            > > > > >
            > > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://www.discovertravelandtours.co...Location=Germa[color=blue][color=green][color=darkred]
            > > > > ny
            > > > > >
            > > > > > To another XML file
            > > > > >
            > > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green][color=darkred]
            > > > > any
            > > > > >
            > > > > > As you can see the second one is not being output with the element[/color]
            > > names[color=darkred]
            > > > 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[/color][/color][/color]
            make[color=blue]
            > it[color=green][color=darkred]
            > > > > > 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
            > > > > >
            > > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Pete

              #7
              Re: XSLT - Help!

              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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
              news:be3ugs$197 $1$830fa7b3@new s.demon.co.uk.. .[color=blue]
              > 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$ 4O4.8790@newsfe p2-win.server.ntli .net...[color=green]
              > > Hi Pete,
              > >
              > > Ah, I see, that's an IE 'problem' - it always thinks that[/color][/color]
              transformations[color=blue][color=green]
              > > 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[/color][/color]
              get[color=blue][color=green]
              > > 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[/color][/color]
              to[color=blue][color=green]
              > > 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" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
              > > news:be3rt2$l6v $1$8302bc10@new s.demon.co.uk.. .[color=darkred]
              > > > Thankyou for your replies,
              > > >
              > > > Yes you are correct the first link i give is not the same xml doc as[/color][/color][/color]
              the[color=blue][color=green][color=darkred]
              > > > second link - the second one has the style sheet applied. I included[/color][/color][/color]
              the[color=blue][color=green][color=darkred]
              > > > 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[/color]
              > > from[color=darkred]
              > > > the following link:
              > > >[/color]
              > >[/color]
              >[/color]
              http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green]
              > > any[color=darkred]
              > > >
              > > > The output is still "text"
              > > > Or at least it is displaying as text, the output may very well be XML[/color][/color]
              > and[color=green][color=darkred]
              > > > 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$ VZ4.30756@newsf ep2-gui.server.ntli .net...
              > > > > Hi Pete,
              > > > >
              > > > > > I have an XSLT file which should be transforming a straight XML[/color][/color][/color]
              file[color=blue][color=green][color=darkred]
              > > > > >
              > > > > >
              > > > >
              > > >[/color]
              > >[/color]
              >[/color]
              http://www.discovertravelandtours.co...Location=Germa[color=blue][color=green][color=darkred]
              > > > > ny
              > > > > >
              > > > > > To another XML file
              > > > > >
              > > > > >
              > > > >
              > > >[/color]
              > >[/color]
              >[/color]
              http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green][color=darkred]
              > > > > any
              > > > >
              > > > > Are you sure you have that the right way round? Looks like the[/color][/color][/color]
              second[color=blue][color=green]
              > > XML[color=darkred]
              > > > > 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[/color][/color]
              > XML[color=green][color=darkred]
              > > > > 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[/color][/color]
              > doing -[color=green][color=darkred]
              > > > > explicit output elements will be cleaner and usually faster[/color][/color][/color]
              (depending[color=blue][color=green]
              > > on[color=darkred]
              > > > > the transformation engine used).
              > > > >
              > > > > If you are transforming the other XML file then you just need to[/color]
              > > change...[color=darkred]
              > > > > <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[/color][/color][/color]
              accept[color=blue][color=green]
              > > the[color=darkred]
              > > > > first - but that's just an MS goof).
              > > > >
              > > > > Hope this helps
              > > > > Marrow
              > > > > http://www.marrowsoft.com - home of Xselerator (XSLT IDE and[/color][/color][/color]
              debugger)[color=blue][color=green][color=darkred]
              > > > > http://www.topxml.com/Xselerator
              > > > >
              > > > >
              > > > > "Pete" <pbarnsley@NOSP AMdiscovertrave landtours.com> wrote in message
              > > > > news:be3nbp$ajr $1$8300dec7@new s.demon.co.uk.. .
              > > > > > I am just getting to grips with XML and I was wondering if you[/color][/color][/color]
              could[color=blue][color=green][color=darkred]
              > > > 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[/color][/color][/color]
              file[color=blue][color=green][color=darkred]
              > > > > >
              > > > > >
              > > > >
              > > >[/color]
              > >[/color]
              >[/color]
              http://www.discovertravelandtours.co...Location=Germa[color=blue][color=green][color=darkred]
              > > > > ny
              > > > > >
              > > > > > To another XML file
              > > > > >
              > > > > >
              > > > >
              > > >[/color]
              > >[/color]
              >[/color]
              http://www.discovertravelandtours.co...?Location=Germ[color=blue][color=green][color=darkred]
              > > > > any
              > > > > >
              > > > > > As you can see the second one is not being output with the element[/color]
              > > names[color=darkred]
              > > > 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[/color][/color][/color]
              make[color=blue]
              > it[color=green][color=darkred]
              > > > > > 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
              > > > > >
              > > > > >
              > > > >
              > > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              Working...