[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: For this input element, fire all matching template

Subject: Re: For this input element, fire all matching template rules. Any way to fire multiple template rules for an input element?
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Tue, 20 Apr 2010 10:00:42 +0200
Re:  For this input element
I don't know how close this is to your facet report, but it does
extract all facets, with @value and the ancestor (element, attribute,
simpleType, complexType) with which it should be reported. (Some
facets are missing.)
-W

<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wl="wolfgang.laun">

<xsl:output method="text"/>

<xsl:function name="wl:report">
  <xsl:param name="ancestor"/>
  <xsl:param name="facetname"/>
  <xsl:param name="facetvalue"/>
  <xsl:value-of select="concat('in ',node-name($ancestor),
' ',$ancestor/@name,': ',$facetname,'=',$facetvalue)"/>
<xsl:text>
</xsl:text>
</xsl:function>

<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
  <xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="text()"/>

<xsl:template match="xs:minLength|xs:maxLength|
                     xs:minInclusive|xs:maxInclusive|
                     xs:enumeration">
  <xsl:variable name="ancestor" select="ancestor::*[@name][1]"/>
  <xsl:value-of select="wl:report($ancestor,node-name(.),./@value)"/>
</xsl:template>

</xsl:stylesheet>


On Mon, Apr 19, 2010 at 2:12 PM, Costello, Roger L. <costello@xxxxxxxxx>
wrote:
>
> Hi Folks,
>
> I have an XSLT program that analyzes XML Schema documents.
>
> My XSLT creates a report if an element that uses the maxLength facet. It
creates a (separate) report if the element uses the minLength facet. In fact,
it creates a separate report for each facet used.
>
> Consider this element declaration:
>
>    <element name="Author">
>        <simpleType>
>            <restriction base="string">
>                <minLength value="1" />
>                <maxLength value="256" />
>            </restriction>
>        </simpleType>
>    </element>
>
> What I really want is to create a template rule for each report:
>
>    <xsl:template
match="xs:element[xs:simpleType/xs:restriction/xs:minLength]">
>        <!-- report on the use of the minLength facet -->
>    </xsl:template>
>
>    <xsl:template
match="xs:element[xs:simpleType/xs:restriction/xs:maxLength]">
>        <!-- report on the use of the maxLength facet -->
>    </xsl:template>
>
>    <xsl:template
match="xs:element[xs:simpleType/xs:restriction/xs:enumeration]">
>        <!-- report on the use of the enumeration facet -->
>    </xsl:template>
>
>    <xsl:template
match="xs:element[xs:simpleType/xs:restriction/xs:pattern]">
>        <!-- report on the use of the pattern facet -->
>    </xsl:template>
>
>    Etc.
>
> And have all applicable rules fire. For the above example, the first two
rules should fire.
>
> Unfortunately this doesn't work. I get an error saying the XSLT program is
ambiguous because multiple rules are applicable.
>
> Is there any way to create an XSLT program and specify, "For this input
element, fire all matching template rules."
>
> /Roger

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.