xsl-list
[Top] [All Lists]

Can't make template match root element with schema info

2005-03-14 20:17:38
Greetings, all!

It took me way too long to figure out what the problem is and I can't seem to find the answer in the FAQ or lists.

I'm using Altova XML-SPY Home Edition, version 2005 release 3. I also tried instant Saxon with similar results.

I am trying to create a stylesheet to format an HR-XML Resume XML document. Seemed like a good idea at the time...

Given an xml document that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="resume.xslt"?>
<Resume xml:lang="EN" xmlns="http://ns.hr-xml.org/2004-08-02"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://ns.hr-xml.org/2004-08-02
http://ns.hr-xml.org/2_3/HR-XML-2_3/SEP/Resume.xsd"; >
  <ResumeId>
    <IdValue>jkg20050310-000</IdValue>
  </ResumeId>
  <StructuredXMLResume>
  </StructuredXMLResume>
  <NonXMLResume>
  </NonXMLResume>
</Resume>
and the stylesheet that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:xs="http://www.w3.org/2001/XMLSchema";
>
  <xsl:output method="xml"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes" />
    <xsl:template match="/">
<xsl:comment>Matched <xsl:value-of select="name(current())"></xsl:value-of></xsl:comment>
      <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="Resume">
<xsl:comment>Matched <xsl:value-of select="name(current())"></xsl:value-of></xsl:comment>
    </xsl:template>
</xsl:stylesheet>
I get the following output:
<?xml version="1.0" encoding="UTF-8"?><!--Matched -->jkg20050310-000
If I remove the schema information from the root tag of the xml document:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="resume.xslt"?>
<Resume>
  <ResumeId>
    <IdValue>jkg20050310-000</IdValue>
  </ResumeId>
  <StructuredXMLResume>
  </StructuredXMLResume>
  <NonXMLResume>
  </NonXMLResume>
</Resume>
I get the following (more or less expected) output:

<?xml version="1.0" encoding="UTF-8"?><!--Matched -->
<!--Matched Resume-->
I must be missing something really basic here as I don't understand why the schema related attributes of the xml root tag prevent it from matching 'Resume' in the stylesheet. Why are attributes affecting this at all?

I did try including the HR-XML namespace in the style sheet and using a qualified XPath expression in the match ( match="hr:Resume") but that made no difference in the result.

Thanks in advance!

        Ken Gentle



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--