XslTransform.transform does not generate xhtml

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default XslTransform.transform does not generate xhtml

    Hi, I am working on a asp.net project that takes a xml
    source and use XslTransform.transform to generate a xhtml
    output.

    The problem with using XslTransform is that it
    automatically reformats the output as HTML instead of
    xhtml. For example, if the xslt file contains <img
    src="..." />, the result html file is <img src="..." > and
    this is not well formed xhtml.

    Is there a way to prevent this aut-reformatting from
    happening? I have been testing with the simplest examples:

    say the xslt is:
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:template match="/">
    <html><body>image<img src="#" /></body></html>
    </xsl:template>
    </xsl:stylesheet>

    The resulting html is:
    <html>
    <body>image<img src="#"></body>
    </html>

    It is perfectly fine xml, but not xhtml since the "/" is
    removed.

    However, if I remove "<html><body>" etc from the xslt file:
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:template match="/">
    image<img src="#" />
    </xsl:template>
    </xsl:stylesheet>

    I do get what I want:
    <?xml version="1.0" encoding="utf-8"?>
    image<img src="#" />

    So, something is reformatting the html output when there
    is <html> tag existing. How to turn it off?


    Thanks.

    Bob Yuan Guest

  2. Similar Questions and Discussions

    1. XHTML and XSTL
      HI, I am working on a document management system. The system gives output in xhtml format. I am using Flex as the presentation tier, I wanted to...
    2. XHTML
      Should I convert my doc to XHML? I am getting rather confused. I done it to a doc and then tested it at w3c and had a ton of errors, I had less...
    3. cfgraph and XHTML
      Hello all, I have an XHTML 1 Strict page that includes a cfgraph Flash graphic. I've seen that the HTML code generated is not XHTML: tags are in...
    4. html > Xhtml
      Hi, I'm tryin to delete all open <p> tags from the body text of news articles on my site. Im doing this, by : <cfset cleanBody =...
    5. XHTML / CSS
      First, excuse-me for this out of topic message. I am searching a good mailling-list for people trying to write standard XHTML and CSS. ...
  3. #2

    Default Re: XslTransform.transform does not generate xhtml

    | So, something is reformatting the html output when there
    | is <html> tag existing. How to turn it off?

    <xsl:output method="xml" />

    if you don't specify output method, it would guess. And if you have <html>
    there, sets <xsl:output method="html" />

    -- Altair


    Michal A. Valasek Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139