Importing xslt into 1 master xslt then to html


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Importing xslt into 1 master xslt then to html

  1. #1
    Patrick Long Guest

    Importing xslt into 1 master xslt then to html

    I have an xml document that i need to render as html. The html has six
    slight variations depending on the value of a particular element in the xml.
    the html is made up like this

    a Html Table (always the same)

    paragraph text
    paragraph text
    paragraph text

    a Html table consisting of 1 THEAD and 1 TBODY.

    My current solution is six differnt xslt files. They all have the same first
    html table, the text for the paragraphs and the same second table. I have to
    say i think this is rubbish.

    What i would like to be able to do is have an xslt that "imports" an xlst to
    do the first common table, then does it's own specific parapgraph then
    "imports" another xslt to do the second common table.

    My limited knowledge of xslt tells me I cannot do this. The xsl:imports must
    be immediate children of the <xsl:stylesheet> element. If they are imported
    at this level what order of precedence do the imported and local templates
    run in. I obviously need then temapltes to fire in the correct order so as
    to render the html correctly.

    Any ideas?

    Thanks

    Pat







  2. #2
    Steven Sexton Guest

    Re: Importing xslt into 1 master xslt then to html


    One option is to use Named templates. You could import all of the different
    templates, then use <xsl:call-template> to call the correct one.

    I am not sure exactly what you are doing, but if the varations are slight
    then you might be able to do the same thing with <xsl:choose>

    Steven

    "Patrick Long" <Patrick_long@csi.com> wrote:
    >I have an xml document that i need to render as html. The html has six
    >slight variations depending on the value of a particular element in the

    xml.
    >the html is made up like this
    >
    >a Html Table (always the same)
    >
    >paragraph text
    >paragraph text
    >paragraph text
    >
    >a Html table consisting of 1 THEAD and 1 TBODY.
    >
    >My current solution is six differnt xslt files. They all have the same first
    >html table, the text for the paragraphs and the same second table. I have

    to
    >say i think this is rubbish.
    >
    >What i would like to be able to do is have an xslt that "imports" an xlst

    to
    >do the first common table, then does it's own specific parapgraph then
    >"imports" another xslt to do the second common table.
    >
    >My limited knowledge of xslt tells me I cannot do this. The xsl:imports

    must
    >be immediate children of the <xsl:stylesheet> element. If they are imported
    >at this level what order of precedence do the imported and local templates
    >run in. I obviously need then temapltes to fire in the correct order so

    as
    >to render the html correctly.
    >
    >Any ideas?
    >
    >Thanks
    >
    >Pat
    >
    >
    >
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center