Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2006, 06:40 AM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default <meta> tag is appearing in xml file

Hi,

Following is my input xml file:

<items>
    <item id="i01">Glass</item>
    <item id="i02">Table</item>
</items>


The output xml(say items_new.xml) will be looked like below:
------------------------------------------------------------

<html>
        <head>
        <title>Different Items</title>
    </head>
    <body>
        <items>
            <item id="i01">Glass</item>
            <item id="i02">Table</item>
        </items>
    </body>
</html>

I have written the xsl file in which I havn't mentioned about <meta> tag. But in output xml file <meta> tag is coming. Since <meta> is not closed in output xml it is giving error as 'File is not Well Formed'.

Any idea how to remove this <meta> in the output xml.


items.xsl
-------------------------------------------------------

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <html>
            <head>
                <title>Different Items</title>
            </head>
            <body>
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="items">
        <xsl:copy>
            <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="node() | @*">
        <xsl:copy>
            <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>


items_new.xml
--------------------------------------------------

<html>
    <head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <title>Different Items</title>
    </head>
    <body>
        <items>
            <item id="i01">Glass</item>
            <item id="i02">Table</item>
        </items>
    </body>
</html>

Thanks in advance.

Saurabh

 
Old April 24th, 2006, 06:46 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Because the outermost element of your result document is <html>, the system defaults to using the HTML output method. If you want the XML output method to be used, specify <xsl:output method="xml"/>.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 24th, 2006, 11:56 PM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael. It is working now.


--Saurabh






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert <META> tag using XSLT on client? Abdul Hameed XSLT 2 September 19th, 2004 12:24 PM
How to dynamically insert <META> tag in .HTML? Abdul Hameed Javascript 1 August 11th, 2004 10:03 AM
How to insert <META> Tag using XSLT on client Abdul Hameed XML 0 August 10th, 2004 11:34 PM
how to dynamically insert <META> tag in .html Abdul Hameed XSLT 1 August 10th, 2004 03:58 AM
XML Parsing error: require </META> disaacs XSLT 1 August 6th, 2004 01:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.