[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL embedded in XML

Subject: XSL embedded in XML
From: Gabriel Kleinoscheg <gabriel.kleinoscheg@xxxxxx>
Date: Mon, 18 Apr 2011 14:16:28 +0200
 XSL embedded in XML
Hello Everybody!

I'm still struggling with the following XML and XSL files. In the first
example I've separated the XML and the XSL:

XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='test02.xsl'?>
<target xmlns="urn:asdf">
  <title>This is the title</title>
</target>

XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:n="urn:asdf" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:value-of select="n:target/n:title"/>
        </title>
      </head>
      <body>
        <h1>
          <center>
            <xsl:value-of select="n:target/n:title"/>
          </center>
        </h1>
      </body>
    </html>
  </xsl:template>
  <!--xsl:template match="xsl:stylesheet"/-->
</xsl:stylesheet>

The example above works quite well in every browser. Now comes the
challenge - embedding the XSL into the XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='#test'?>
<!DOCTYPE target [<!ATTLIST xsl:stylesheet id ID #REQUIRED>]>
<target xmlns="urn:asdf">
  <xsl:stylesheet id="test" xmlns:n1="urn:asdf" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <!-- CDA document -->
    <xsl:template match="/">
      <html>
        <head>
          <meta content="text/html; charset=UTF-8"
http-equiv="Content-Type" />
          <title>
            <xsl:value-of select="n1:target/n1:title"/>
          </title>
        </head>
        <body>
          <h1>
            <center>
              <xsl:value-of select="n1:target/n1:title"/>
            </center>
          </h1>
        </body>
      </html>
    </xsl:template>
    <xsl:template match="xsl:stylesheet"/>
  </xsl:stylesheet>
  <title>This is the title</title>
</target>

I've tested this example - it doesn't show correctly in Firefox and IE
but in Safari. Although when I check the generated source with
WebDeveloper in Firefox I see the correct html-code.

If I write

<n1:target xmlns:n1="urn:asdf">
  <n1:title> ... </n1:title>
</n1:title>

everything works perfectly. But why isn't it possible without the
prefixes in the XML? Why does it work, if XML and XSL are separated but
not when they are within one document?

Hope you can help me. Thank you anyway.

regards, Gabriel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.