Subject: RE: [xsl] Howto generate a list xpath queries that are used within a template? From: "Michael Kay" <mhk@xxxxxxxxx> Date: Sun, 22 Aug 2004 23:04:48 +0100 |
This is a good use case for a schema-aware stylesheet. The attributes that can hold XPath expressions are all described in the schema for XSLT 2.0 stylesheets (published as part of the XSLT 2.0 specification) as being either of type xsl:expression or xsl:avt. This means that if the source document (the input stylesheet) has been validated against this schema, then you can select these attributes using an expression of the form attribute(*, xsl:expression) | attribute(*, xsl:avt). For further refinement you may want to exclude attributes of type xsl:pattern (which is modelled in this schema as a subtype of xsl:expression), and you may want to include AVT attributes only if they contain curly braces. This may be a rather more bleeding-edge solution than anything you had in mind (the only product that will run it at present is the schema-aware version of Saxon 8.0) but it will certainly give you the simplest code. Any other solution will involve a long sequence of conditionals or template rules testing all the attributes that are defined as expressions or AVTs individually. Michael Kay > -----Original Message----- > From: Joren Crauwels [mailto:joren.crauwels@xxxxxxxxxxxxxxx] > Sent: 22 August 2004 14:25 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Howto generate a list xpath queries that are > used within a template? > > Hi, > > for a school project i have to generate a html file > containing metadata > about an xslt file. So i have a file xslt2html.xsl that has > can do this. A > thing that has to be possible is to generate a list of all > the templates and > for each template i have to generate more detailed > information. t has to be > possible to generate a list of used xpath queries within a > template. For the > moment, i use a template like this to do that: > > <xsl:template name="generateUsedXpathQueries"> > <xsl:variable name="bla1" select="'joren'"/> > <xsl:choose> > <xsl:when test="@select"> > <li><xsl:value-of select="@select"/></li> > </xsl:when> > <xsl:when test="@test"> > <li><xsl:value-of select="@test"/></li> > </xsl:when> > </xsl:choose> > </xsl:template> > > The problem with this solution is that i will miss xpath > queries that arent > used in a select or test attribute. Does anyone know how i > can generate a > list that doesnt leave any xpath queries out? is there a way > to check if the > value of an attribute is a xpath-query or not? > > This is my first post so i hope it does reach someone :) > > > Greetz, > Joren
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Howto generate a list xpa, Kenneth Stephen | Thread | [xsl] stylesheet licensing?, Bruce D'Arcus |
Re: [xsl] Howto generate a list xpa, Joren Crauwels | Date | Re: [xsl] Howto generate a list xpa, Kenneth Stephen |
Month |