Re: [xsl] Bad schemas

Subject: Re: [xsl] Bad schemas
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Sat, 27 Jul 2002 09:54:28 +0200
Jeff Shevlen wrote:
Hi,

Can anyone shed some light on why Xalan parses an XML doc with no
schema no namespace (skills)differently than the identical doc
(skills2), with a schema (that is not validating properly yet), and a
namespace?

This is a FAQ. The XPath expressions and template match expressions need an explicit namespace prefix, even if your sourtce XML uses the default namespace and therefore no namespace prefix.

Try

 <?xml version = "1.0" encoding = "UTF-8"?>
 <xsl:stylesheet version = "1.0"
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform";
   xmlns:skills = "http://www.abc.com/skills";>

<xsl:output method = "xml" indent = "yes"/>

   <xsl:template match = "//skills:related_skill">
     <xsl:element name = "test">
       <xsl:text>XXXX   </xsl:text>
       <xsl:attribute name = "skill_IDREF">
         <xsl:value-of select = "@skills:skill_IDREF"/>
       </xsl:attribute>
     </xsl:element>
   </xsl:template>

BTW regarding the template above:
1. You can write it much shorter
2. It probably wont work, because you add the text child
   before the attribute.
Try
   <xsl:template match = "//skills:related_skill">
     <test skill_IDREF="{@skills:skill_IDREF}">
       <xsl:text>XXXX   </xsl:text>
     </test>
   </xsl:template>
instead.

Note that the "test" element is in the default namespace, not
in the skills namespace.

J.Pietschmann


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread