xsl:import and xsl:apply_import

Discussion in 'XML' started by David Carlisle, Dec 16, 2004.

  1. The attributes on xsl:eek:utput are merged according to import precedence,
    you only have one lineariser active in any given transformation.
    In your case the system will output XML, which is presumably what you
    want, as the method attribute on xsl:eek:utput in the first stylesheet has
    higher import precedence.

    the templates in transform2.xsl will still fire, but the text will be
    output using XML conventions so < as &lt; this is anyway what you want
    as you are outputting the child text of an element and if you generated
    unquoted < or & (as the text output method would produce) the whole
    result file would not be well formed XML.


    Presently, the declarations in the imported xsl are ignored.

    If this is so, the problem is unrelated to any of the code you have
    posted, you may need to be more explict, make a small example with one
    template in each stylesheet, and an explict input file and say what
    output you wanted and what output you got.

    David
     
    David Carlisle, Dec 16, 2004
    #1
    1. Advertising

  2. David Carlisle

    Shiju Rajan Guest

    Hi,
    I have one transformation called transform1.xsl.

    transform1.xsl
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="transform2.xsl"/>
    <xsl:eek:utput method="xml"/>
    -------------------------------------------
    <xsl:apply-imports/>
    -------------------------------------------
    -------------------------------------------
    </xsl:template>
    </xsl:stylesheet>

    I have another transformation called transform2.xsl.
    transform2.xsl
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="text"/>
    -------------------------------------------
    -------------------------------------------
    -------------------------------------------
    </xsl:template>
    </xsl:stylesheet>

    I want the final XML document to have text portions wherever I have done
    an apply-imports. Can you please tell me how can this be achieved? Presently,
    the declarations in the imported xsl are ignored.

    Regards,
    Shiju,
     
    Shiju Rajan, Dec 16, 2004
    #2
    1. Advertising

  3. David Carlisle

    Shiju Rajan Guest

    David Carlisle <> wrote:
    >
    >The attributes on xsl:eek:utput are merged according to import precedence,
    >you only have one lineariser active in any given transformation.
    >In your case the system will output XML, which is presumably what you
    >want, as the method attribute on xsl:eek:utput in the first stylesheet has
    >higher import precedence.
    >
    >the templates in transform2.xsl will still fire, but the text will be
    >output using XML conventions so < as < this is anyway what you want
    >as you are outputting the child text of an element and if you generated
    >unquoted < or & (as the text output method would produce) the whole
    >result file would not be well formed XML.
    >
    >
    > Presently, the declarations in the imported xsl are ignored.
    >
    >If this is so, the problem is unrelated to any of the code you have
    >posted, you may need to be more explict, make a small example with one
    >template in each stylesheet, and an explict input file and say what
    >output you wanted and what output you got.
    >
    >David


    Hi,
    Using the transforms below as examples.

    transform1.xsl
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="transform2.xsl"/>
    <xsl:eek:utput method="xml"/>
    -------------------------------------------
    <xsl:apply-imports/>
    -------------------------------------------
    -------------------------------------------
    </xsl:template>
    </xsl:stylesheet>

    I have another transformation called transform2.xsl.
    transform2.xsl
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="text"/>
    -------------------------------------------
    -------------------------------------------
    -------------------------------------------
    </xsl:template>
    </xsl:stylesheet>

    The transformation transform2.xsl will generate a perl if statement where
    I need to output && instead of &amp;&amp;. If I put && in that transform
    then it gives a parse error therefore I have it output text.

    Regards,
    Shiju,
     
    Shiju Rajan, Dec 16, 2004
    #3
  4. Hi,
    Using the transforms below as examples.


    you included those in your first post, they are not examples that can be
    used, they have no templates in them and have text ---- at places where
    xslt doesn't allow text.

    The transformation transform2.xsl will generate a perl if statement where
    I need to output && instead of &amp;&amp;. If I put && in that transform
    then it gives a parse error therefore I have it output text.

    An XSLT stylesheet has to be well formed XML to specify && in _any_ XML
    you need to write that as &amp;&amp; otherwise it won't parse as XML
    and XSLt won't start. &amp;&amp; however produces a string of length 2
    not a string of length 10, hiw that string is written to teh result is
    independent of the way it was input. In an xml or html output methid it
    will be written as &amp;&amp; in a text output method it will be
    written as &&.

    If you are generating an XML file then you can't have && in the result
    or at least you can but it has to be quoted as &amp;&amp; If you are
    generating a text file rather than XMl make sure your highest precedence
    method attribute on xsl:eek:utput is text. You haven't said which of these
    you are trying to do.

    the output method is a property of the entire transform, conceptually it
    happens _after_ the transform, specifying how to write the result tree
    of nodes to a linear markup in a file.



    So, if your aim is to produce an XML file containing perl codes as
    element content than &amp;&amp; is the result that you need.

    If your aim is to produce a text file containing perl code then you need
    xsl:eek:utput method="text".

    Your problem dosn't seem directly related to xsl:import at all.

    David
     
    David Carlisle, Dec 16, 2004
    #4
  5. As you can see in my original post and your
    answers, all your "amp; amp;" have been replaced with a &&

    It's your newsreader that's at fault rather than the newsgroup itself
    (probably it's trying to guess that stuff that _looks_ like html _is_
    html.

    however that's fairly common, over on xsl-list we normally try to write
    things as "& a m p ;" spaced out to avoid that problem, sorry I forgot
    to do that here.

    David
     
    David Carlisle, Dec 16, 2004
    #5
  6. David Carlisle

    Shiju Rajan Guest

    David Carlisle <> wrote:
    >
    > Hi,
    > Using the transforms below as examples.
    >
    >
    >you included those in your first post, they are not examples that can be
    >used, they have no templates in them and have text ---- at places where
    >xslt doesn't allow text.
    >
    > The transformation transform2.xsl will generate a perl if statement

    where
    > I need to output && instead of &&. If I put && in that transform
    > then it gives a parse error therefore I have it output text.
    >
    >An XSLT stylesheet has to be well formed XML to specify && in _any_ XML
    >you need to write that as && otherwise it won't parse as XML
    >and XSLt won't start. && however produces a string of length 2
    >not a string of length 10, hiw that string is written to teh result is
    >independent of the way it was input. In an xml or html output methid it
    >will be written as && in a text output method it will be
    >written as &&.
    >
    >If you are generating an XML file then you can't have && in the result
    >or at least you can but it has to be quoted as && If you are
    >generating a text file rather than XMl make sure your highest precedence
    >method attribute on xsl:eek:utput is text. You haven't said which of these
    >you are trying to do.
    >
    >the output method is a property of the entire transform, conceptually it
    >happens _after_ the transform, specifying how to write the result tree
    >of nodes to a linear markup in a file.
    >
    >
    >
    >So, if your aim is to produce an XML file containing perl codes as
    >element content than && is the result that you need.
    >
    >If your aim is to produce a text file containing perl code then you need
    >xsl:eek:utput method="text".
    >
    >Your problem dosn't seem directly related to xsl:import at all.
    >
    >David


    Hi David,
    I think I got your answer from "however produces a string of length 2
    >not a string of length 10, " As you can see in my original post and your

    answers, all your "amp; amp;" have been replaced with a && therefore it seems
    this newsgroup is also using some xml to produce the output which is replacing
    my "amp;amp;" with &&.

    Thanks a lot.

    Shiju,
     
    Shiju Rajan, Dec 16, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    1,003
    Paul Opal
    Oct 11, 2004
  2. Replies:
    1
    Views:
    3,686
    A. Bolmarcich
    May 27, 2005
  3. Andrew James
    Replies:
    1
    Views:
    1,005
    Diez B. Roggisch
    Dec 4, 2004
  4. Eric Hanchrow
    Replies:
    1
    Views:
    385
    Arnaud Delobelle
    May 9, 2008
  5. J. Cliff Dyer
    Replies:
    2
    Views:
    349
    Chuckk Hubbard
    May 8, 2008
Loading...

Share This Page