Re: [xsl] Find attribute of node derived from extended base of ComplexType

Subject: Re: [xsl] Find attribute of node derived from extended base of ComplexType
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jun 2004 19:06:32 -0400
At 2004-06-24 00:27 +0200, xdevpj@xxxxxx wrote:
I want to know wheter or not an ancester of a node has an attribute maxOccurs and the value of this attribute.

For nodes like the countries in the example below this is no problem with:

<xsl:when test="ancestor::*/@maxOccurs">
        <xsl:value-of select="ancestor::*/@maxOccurs"/>
</xsl:when>

I get the '3' of the node <xs:element name="ACountry" minOccurs="0" maxOccurs="3">.


The question now is: How do I find the attribute and get the 'unbounded' value of the element: <xs:element name="AnEntry" type="AnEntryType" maxOccurs="unbounded"/>

You don't say if you are using XSLT 1.0, but I'll assume you are.


when the current node is i.e:
<xs:element name="ANumber"> of the extended base of the complexType "AnEntryType"?

XPath 1.0 delivers specified attributes from the start tags and defaulted attributes from an XML 1.0 DTD. XPath 1.0 knows nothing about W3C Schema.


Any Ideas?

I'm working with Universal Business Language (UBL) Schemas that are written in W3C Schema and they have defaulted attributes as well ... and I'm using XSLT/XPath 1.0 so I'm faced with the same problem you have.


I run my XML instances through the Xerces DOMPrint sample application before applying the XSLT/XPath 1.0 stylesheet. This utility will output an XML document complete with W3C Schema defaulted attributes for the input XML document.

There is a W3C schema for W3C schemas, so I suspect if you ran your schema through DOMPrint you would end up with a "fleshed-out" schema complete with defaulted attributes from the schema for schemas, and then you can run your XSLT/XPath 1.0 stylesheet against that output instance.

I hope this helps.

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

--
Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23
World-wide on-site corporate, govt. & user group XML/XSL training.
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)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


Current Thread