setting DOCTYPE and also including a file in the output

Discussion in 'XML' started by danmc91, Dec 31, 2006.

  1. danmc91

    danmc91 Guest

    Hello,

    I'm new to xml and xslt but that should be obvious from my question.

    I'm trying to help my wife set up some web pages with some of her art
    work and what I'm trying to do is find a way to get all of the
    information about the pictures in an XML file and then use xslt to
    produce some different html files.

    My first problem is I can't seem to figure out how to get this to
    appear at the top of my output file:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    The next problem I'm having is how to include an extra file in the
    output. I had some very old scripts which could parse html files with
    server side includes and produce static html files that didn't need a
    server with SSI enabled. I'd been using this mechanism to include a
    standard footer and some navigation links on all web pages. Since I'm
    looking to migrate towards xml and xslt I'm trying to find a way to
    still include the contents of a file in the output.

    The .dtd file .xsl file, and input .xml file's I have so far are at:

    http://home.comcast.net/~dmcmahill/tmp/gallery.dtd
    http://home.comcast.net/~dmcmahill/tmp/gallery.xsl
    http://home.comcast.net/~dmcmahill/tmp/drawings1.xml

    xsltproc gallery.xsl drawings1.xml > drawings1.shtml

    seems to give the right thing except for the DOCTYPE bit and I still
    need to run my homebrewed SSI processor to convert the .shtml file to
    ..html.

    Any suggestions? Am I going about this completely the wrong way? For
    how much programming in all sorts of languages, I'm finding xslt rather
    confusing...

    -Dan
    danmc91, Dec 31, 2006
    #1
    1. Advertising

  2. danmc91 wrote:

    > My first problem is I can't seem to figure out how to get this to
    > appear at the top of my output file:
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Use the xsl:eek:utput instruction e.g.
    <xsl:eek:utput
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"

    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>





    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 1, 2007
    #2
    1. Advertising

  3. danmc91 wrote:

    > The next problem I'm having is how to include an extra file in the
    > output. I had some very old scripts which could parse html files with
    > server side includes and produce static html files that didn't need a
    > server with SSI enabled. I'd been using this mechanism to include a
    > standard footer and some navigation links on all web pages.


    The XSLT language has an xsl:include instruction to include stylesheet
    modules. Then there is the document function to load secondary XML
    documents to be processed besides the main XML input.

    That means you have two choices, if the footer is a snippet of
    well-formed X(HT)ML (e.g.
    <div xmlns="http://www.w3.org/1999/xhtml">
    <p>....</p>
    </div>
    ) then you can pull it in with the document function and simply copy it
    to the result tree e.g.
    <xsl:copy-of select="document('footer.xml')/*"/>
    Note the namespace declaration above in the snippet, if your aim is to
    output XHTML then the separate file needs to have the XHTML namespace
    declaration present if you simply want to copy the elements.

    Alternatively you could write a stylesheet module with a named template
    making up the footer e.g.
    <xsl:template name="make-footer" xmlns="http://www.w3.org/1999/xhtml">
    <div>
    <p>...</p>
    </div>
    </xsl:template>
    then include that stylesheet with xsl:include and call e.g.
    <xsl:call-template name="make-footer"/>
    where you want to include the footer.

    These are the tools XSLT 1.0 offers, additionally you might want to look
    into XInclude to compose XML from different sources independent of XSLT.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 1, 2007
    #3
  4. danmc91

    danmc91 Guest

    Thanks Martin! Both of your suggestions worked and did exactly what I
    was trying to do.

    -Dan
    danmc91, Jan 1, 2007
    #4
    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. Kenneth Keeley

    Setting DocType in Asp.Net

    Kenneth Keeley, Jun 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    607
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jun 30, 2004
  2. Michael Preminger

    Setting DOCTYPE to a DOM- document

    Michael Preminger, Dec 20, 2004, in forum: Java
    Replies:
    5
    Views:
    11,923
    John C. Bollinger
    Dec 22, 2004
  3. Replies:
    11
    Views:
    1,389
  4. johkar

    XHTML - Doctype and output

    johkar, Oct 8, 2004, in forum: XML
    Replies:
    3
    Views:
    832
    johkar N
    Oct 9, 2004
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,271
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page