This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 8573 - F.1 Stylesheet for chameleons invalid
Summary: F.1 Stylesheet for chameleons invalid
Status: CLOSED FIXED
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Structures: XSD Part 1 (show other bugs)
Version: 1.1 only
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: David Ezell
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords: resolved
Depends on:
Blocks:
 
Reported: 2009-12-31 16:12 UTC by Hans-Juergen Rennau
Modified: 2010-08-18 20:04 UTC (History)
1 user (show)

See Also:


Attachments
revised stylesheet for chameleon include (2.34 KB, application/xml)
2010-08-16 17:11 UTC, C. M. Sperberg-McQueen
Details

Description Hans-Juergen Rennau 2009-12-31 16:12:37 UTC
The stylesheet contains several errors, e.g. referencing the context item within a stylesheet function. Proposed correction as follows. Another issue - the stylesheets "forgets" to handle the attribute 'memberTypes' - is dealt with in a separate bug report.

With kind regards -
Hans-Juergen Rennau




<xsl:transform version="2.0"
               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
               xmlns:f="http://www.w3.org/2008/05/XMLSchema-misc">

  <xsl:param name="newTargetNamespace" as="xs:anyURI" 
      required="yes"/>
  <xsl:param name="prefixForTargetNamespace" as="xs:NCName" 
      select="f:generateUniquePrefix(., 0)"/>

  <xsl:template match="@*|node()">
    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
  </xsl:template>

  <xsl:template match="xs:schema">
    <xsl:copy>
     <xsl:namespace name="{$prefixForTargetNamespace}" 
       select="$newTargetNamespace"/>
     <xsl:apply-templates select="@*"/>
     <xsl:attribute name="targetNamespace" 
       select="$newTargetNamespace"/>
     <xsl:apply-templates/>
   </xsl:copy>
  </xsl:template>

  <xsl:template match="attribute(*, xs:QName)
      [namespace-uri-from-QName(.)='']">
    <xsl:attribute name="{name()}" 
      select="concat($prefixForTargetNamespace, 
                     ':', 
                     local-name-from-QName(.))"/>
  </xsl:template>

  <xsl:function name="f:generateUniquePrefix" as="xs:NCName">
    <xsl:param name="xsd"/>
    <xsl:param name="try" as="xs:integer"/>
    <xsl:variable name="disallowed" 
      select="distinct-values($xsd//*/in-scope-prefixes(.))"/>
    <xsl:variable name="candidate" 
      select="xs:NCName(concat('p', $try))"/>
    <xsl:sequence select="if ($candidate = $disallowed) then 
                                f:generateUniquePrefix($xsd, $try+1) 
                             else 
                                $candidate"/>
  </xsl:function>

</xsl:transform>
Comment 1 David Ezell 2010-01-14 19:05:16 UTC
On the telcon on 2010-01-08 the WG decided to accept the suggested changes to the stylesheets, with a request to Sandy Gao to insert these changes into the status quo.
Comment 2 C. M. Sperberg-McQueen 2010-08-16 17:11:39 UTC
Created attachment 907 [details]
revised stylesheet for chameleon include

Attached is the revised form of the stylesheet, which is included in the new status-quo document at 

  http://www.w3.org/XML/Group/2004/06/xmlschema-1/structures.html#chameleon-xslt
  (member-only link)

I believe this resolves the issue, so I'm marking the issue RESOLVED.

As the originator, Hans-Jürgen Rennau is invited to check that the corrections have been made correctly (it's always easy to mess something up) and indicate by either closing or reopening the issue that  he is satisfied, or not satisfied, with the resolution of the issue.  If the WG does not hear from you in the next two weeks or so, we will assume that you are satisfied.  

Thank you very much for catching the errors, and for providing the fixes.
Comment 3 Hans-Juergen Rennau 2010-08-18 20:04:49 UTC
(In reply to comment #2)
Thank you, everything looks fine, I close the issue.