W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2002

Re: Abstract types

From: Mike Haarman <mhaarma@socsci.umn.edu>
Date: Tue, 20 Aug 2002 13:12:12 -0500 (CDT)
To: Mikael Joukakelian <mikaelj@cae.com>
cc: <www-xsl-fo@w3.org>, <xmlschema-dev@w3.org>
Message-ID: <Pine.GSO.4.30.0208201258240.22350-100000@trickster.hist.umn.edu>


Simply,

<xsl:template match="*">
  <dl>
    <dt><xsl:value-of select="name()"/></dt>
    <xsl:for-each select="@*">
      <dd> has attribute <xsl:value-of select="name()"/> = <xsl:value-of select="."/></dd>
    </xsl:for-each>
  </dl>
</xsl:template>

A question like this belongs to the xslt-list@lists.mulberrytech.com.  But
to be honest, something this basic would not be likely to get a rise.

Cheers,

Mike


On Tue, 20 Aug 2002, Mikael Joukakelian wrote:

>
> Hi all,
>
> My schema defines over a hundred elements with a varying number of
> attributes in each. I want to convert instances of this schema into HTML for
> documentation purposes. I can make a conversion similar to the following:
>
> <Element1 att1="34" att2="567"/>
>
> Convering the above to HTML with the following display:
>
> Element1 has attribute att1 = 34 and att2 = 567
>
> Using the XSLT below:
>
> <xsl:template match="Element1">
> 		<ul type="disc">
> 			<li>Element1 has attibute
> 				<xsl:for-each select="@att1"> att1 =
> <xsl:value-of select="."/>
> 				</xsl:for-each>
> 				<xsl:for-each select="@att2"> att2 =
> <xsl:value-of select="."/>
> 				</xsl:for-each>
> 			</li>
> 		</ul>
> </xsl:template>
>
>
> First, is there a way to print the name of the tag of an element/attribute
> so that when I do a match or select I can print the tag name automatically,
> i.e, match="Element1" and print it's name, select="@att1" and print it's
> name?
>
> Secondly, I need to do this for all Element1, Element2, ... Element100. This
> makes for a lengthy and error prone XSLT file. Is there a way to write a
> template that can match any element; output the name; add the text " has
> attribute "; select all attributes; output their names; add the text " = ";
> and output their values? It may be of worth to mention that all my elements
> have substitutionGroup="AbstractElement" which is an abstract element.
>
> Thanks
> Mikael
>
>

----------------------------------------------------------------
Mike Haarman
mhaarma@socsci.umn.edu
Received on Tuesday, 20 August 2002 14:12:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT