[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML class descriptor



On Wed, 23 Feb 2000, Steve Tinney wrote:
> > >
> > > It does.  Are you sure, though, that nobody will ever want to, say, run this
> > > stuff through XSL for some reason?  Of course, one can parse a delimited
> > > string in XSL as well, so there's not much in it.
> > No, I'm not sure. What are the possible drawback of the current solution
> > regarding XSL?
> > 
> 
> It's not a big deal, but there is an issue of going with the natural
> flow of the language features.  Processing lists of nodes in XSL is very
> easy, and there is a range of idioms to support it including specifying
> templates to match on given nodes in given contexts and explicit looping
> like:
> 
>  	<xsl:for-each select="xparameter">
>            ...
>         </xsl:for-each>
> 
> Which selects all xparameter children of the current node (e.g., an
> xmethod) and does the ... stuff to them with the xparameter set
> temporarily to the current node.  If you wished, you could print a list
> of all classes used as arguments in all methods and constructors by
> saying something like:
> 
>  <xsl:for-each select="//xparameter">
>    <xsl:sort select="."/>
>    <xsl:if test="not(. = following-sibling::xparameter[1])">
>      <xsl:message><xsl:value-of select="."/></xsl:message>
>    </xsl:if>
>  <xsl:for-each>
> 
> (XSL doesn't have good facilities yet for grouping/uniquing, hence the
> following-sibling:: stuff.  Several of the processors have extension
> functions which make complex grouping or node-set manipulation easier,
> and additional facilities for these things are also intended for future
> versions of XSL).
> 
> There are string-handling capabilities in XSL, but to parse the separate
> parameters out of an attribute string you'd need to use a recursive
> function, something like:
> 
>         <xsl:call-template name="do-params">
>           <xsl:with-param name="parameters" select="@parameters"/>
>         </xsl:call-template>
> 
>         <xsl:template name="do-params">
>           <xsl:param name="parameters"/>
>           <xsl:variable name="one-param" 
>              select="string-before(parameters,'|')"/>
>           <xsl:if test="string-length($one-param) > 0">
>             <xsl:call-template name="do-to-one-param">
>               <xsl:with-param name="one-p" select="$one-param"/>
>             </xsl:call-template>
>           </xsl:if>
>           <xsl:variable name="next-params" 
>             select="string-after(parameters,'|')"/>
>           <xsl:if test="string-length($next-params) > 0">
>             <xsl:call-template name="do-params">
>               <xsl:with-param name="parameters"
>                               select="$next-params"/>
>             </xsl:call-template>
>           </xsl:if>
>         </xsl:template>
> 
>         <xsl:template name="do-to-one-param">
>            <xsl:with-param name="one-p"/>
>            ...
>         </xsl:template>
> 
> So, you see, it's easier the element-way... (the above code is untested
> by the way, and may be not only voluminous but also malfunctional).

Thanks for the explanation. I have to learn more about this XML/XSL stuff ;)

Ok, I will change the schema to not use attributes. The example would then be
something like:

<?xml version="1.0"?>
<javaobject>
	<name>button<name/>
	<package>java.awt</package>
	<superclass>java.awt.Component</superclass>
	<constructors>
		<xconstructor>
			<parameter>java.lang.String<parameter/>
		<xconstructor/>
	</constructors>
	<methods>
		<xmethod>
			<name>toString<name/>
			<parameter>java.lang.Object<parameter/>
			<locklevel>READ<locklevel/>
		</xmethod>
	</methods>
</javaobject>

Other ideas?


Falko
-- 
______________________________________________________________________
Falko Braeutigam                         mailto:falko@softwarebuero.de
softwarebuero m&b (SMB)                    http://www.softwarebuero.de