Re: [xsl] XSLT 2 processing of W3C Schema expressed default attributes

Subject: Re: [xsl] XSLT 2 processing of W3C Schema expressed default attributes
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 03 Sep 2003 07:04:23 -0400
At 2003-09-02 23:26 +0100, Peter Flynn wrote:
On Tue, 2003-09-02 at 16:24, G. Ken Holman wrote:
> My expectations of the instance and document model below are that a
> schema-aware XSLT 2 processor will "see" the default attribute expressed in
> the W3C Schema expression and this attribute will show up in a copy-of for
> the entire document. I'm expecting the output <entry1> will have
> defattr="hello" included since I didn't specify such an attribute in the input.


Like performing normalization on it? That's interesting -- I wouldn't
have expected that behavior; I would have expected copy-of to produce a
literal copy with no additions.

Note below that a DTD supplements the information set with defaulted attributes. This is the behaviour I am looking for from a W3C Schema-aware XSLT 2 processor ... so I need an XSLT 2 processor that acts on the PSVI of a document, not the XML information set of a document.


................... Ken

V:\samp>type defattrd.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE doc [
<!ELEMENT doc ( entry1, entry2 )>
<!ELEMENT entry1 ( #PCDATA )>
<!ATTLIST entry1 defattr CDATA "hello">
<!ELEMENT entry2 EMPTY>
<!ATTLIST entry2 attr CDATA #REQUIRED>
]>
<doc>
  <entry1>AB</entry1>
  <entry2 attr="CD"/>
</doc>

V:\samp>type copyofall2.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="2.0">

<xsl:template match="/">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>
V:\samp>xslt2 defattrd.xml copyofall2.xsl con
<?xml version="1.0" encoding="UTF-8"?><doc>
  <entry1 defattr="hello">AB</entry1>
  <entry2 attr="CD"/>
</doc>
V:\samp>



--
Next public European delivery:  3-day XSLT/2-day XSL-FO 2003-09-22
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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



Current Thread