You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Brian Atkins <br...@firehunter.com> on 2001/10/01 23:26:10 UTC

HTML Tags in source, namespaces, etc. (yes, help!)

Folks,

I am trying to pass HTML tags from the source XML document to the
result using an XSLT stylesheet.  I am actually processing XML
Schema documents and producing HTML output which documents the
schema.  The <xs:documentation> tags I have placed in the schema
to document the various elements and attributes have embedded HTML
tags.  I want to pick up the entire contents of the <xs:documentation>
element and pass it through to the result intact.

I have looked at the FAQ and have tried the several suggestions there.
The problem is that the HTML tags acquire namespace nodes as they are
passed through.  The HTML tags placed in the result by the stylesheet
itself are fine (they respect the "exclude-result-prefixes" setting).

Below are the stylesheet, schema, and HTML result.  I process the
documentation tags explicitly in the style sheet, and override the
default template to do nothing.  I have cut out everything from the
stylesheet and schema which isn't relevant to the problem.

Notice that the <BR/> tag in the Schema gets output in the HTML result
with xmlns tags added.  However, the HTML tag, which would normally also
have these attributes, is clean (due to the exclude-result-prefixes
attribute in the style sheet element).

Should the exclude-result-prefixes directive also effect tags processed by
copy-of?

I have tried several permutations of copy, copy-of, and apply-templates.
I either get the same behavior as below, or I get all the HTML
tags from the Schema document stripped out.

All I want to to pass the <BR/> tag (and other HTML tags in the source)
through unscathed.

In a related area, I can't seem to put a namespace prefix on the HTML
tags in the source document (schema) without them appearing in the result
(namespace-alias appears to only apply to prefixes found in the stylesheet).
This is a problem since the HTML tags do NOT belong to the default namespace
in the schema (and I really don't want to make the target namespace non-default).
Any ideas?

Thanks!
Brian ATkins


<!-- *******  STYLESHEET ******* -->

<?xml version="1.0"?>
<xsl:stylesheet version='1.1'
                xmlns='http://www.firehunter.com/XML/FhReport'
                xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
                xmlns:xs='http://www.w3.org/2001/XMLSchema'
                exclude-result-prefixes='xs #default'>

  <xsl:output method="html"/>

  <xsl:strip-space elements="*"/>

  <!-- TOP LEVEL -->

  <xsl:template match="/xs:schema">
    <HTML>
      <HEAD>
        <TITLE>XMLReport Schema</TITLE>
      </HEAD>
      <BODY>
        <H1>XMLReport Schema</H1>
        <xsl:call-template name="documentation"/>
	<BR/>
	<xsl:apply-templates select="//xs:element"/>
      </BODY>
    </HTML>
  </xsl:template>

  <!-- DOCUMENTATION -->

  <xsl:template name="documentation">
    <xsl:if test="count(xs:annotation/xs:documentation) &gt; 0">
      <xsl:copy-of select="xs:annotation/xs:documentation/node()"/>
      <BR/>
    </xsl:if>
  </xsl:template>

  <!-- override default for documentation to do nothing -->

  <xsl:template match="xs:annotation/xs:documentation"/>

</xsl:stylesheet>

<!-- *******  SCHEMA ******* -->

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<xs:schema targetNamespace='http://www.firehunter.com/XML/FhReport'
           xmlns='http://www.firehunter.com/XML/FhReport'
           xmlns:xs='http://www.w3.org/2001/XMLSchema'
           xml:lang="en">
           
  <xs:annotation>
    <xs:documentation>
      Firehunter XML report interface schema.
      <BR/>
      Copyright (C) 2001 Agilent Technologies Inc. All Rights Reserved.
    </xs:documentation>
  </xs:annotation>

</xs:schema>

<!-- *******  RESULT ******* -->

<HTML>
    <HEAD>
        <TITLE>XMLReport Schema</TITLE>
    </HEAD>
    <BODY>
        <H1>XMLReport Schema</H1>
      Firehunter XML report interface schema.
      <BR xmlns="http://www.firehunter.com/XML/FhReport"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
      Copyright (C) 2001 Agilent Technologies Inc. All Rights Reserved.
    <BR>
        <BR>
    </BODY>
</HTML>


-- 
Brian Atkins          brian_atkins@firehunter.com         (970) 288-2114
Agilent Technologies     4800 Wheaton Drive        Ft. Collins, CO 80525