[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] in-document references
Subject: RE: [xsl] in-document references From: "Robert Koberg" <rob@xxxxxxxxxx> Date: Mon, 6 Jan 2003 16:21:04 -0800 |
Hi, You are not using namespaces, eh? What I do for this is to set a key on the the rng:define's, like: <xsl:key name="defs" match="rng:define" use="@name"/> then when you match your rng:ref's you do: <xsl:apply-templates select="key('defs', @name)/*"/> For the form problem you posed earlier, you should be able to tell what kind of form control to use from things like rng:choice = html:select, rng:oneOrMore = html:input[@type=checkbox] etc... Or use a data type to set form fields, e.g: <rng:define name="description"> <rng:element name="description" a:label="Description" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rng:data type="token"> <rng:param name="maxLength">256</rng:param> </rng:data> </rng:element> </rng:define> Another useful thing to do is use annotations to provide a friendly label and perhaps a default value among other things, like: <rng:define name="language"> <rng:element name="language" a:label="Language" a:default="en" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rng:choice> <rng:value type="NMTOKEN">en</rng:value> <rng:value type="NMTOKEN">bg</rng:value> </rng:choice> </rng:element> </rng:define> and some XSLT (when matching the rng:element): ... <xsl:when test="boolean(rng:choice)"> <select id="{$md_name}{$gen_id}" name="{$md_name}{$gen_id}"> <xsl:for-each select="rng:choice/rng:value"> <xsl:variable name="value" select="normalize-space(.)"/> <option value="{$value}"> <xsl:if test="$current_nodeset_value=$value"> <xsl:attribute name="selected">selected</xsl:attribute> </xsl:if> <xsl:value-of select="$value"/> </option> </xsl:for-each> </select> </xsl:when> ... make sense? best, -Rob > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of S Woodside > Sent: Monday, January 06, 2003 3:07 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] in-document references > > > I'm trying to transform a relax NG (RNG) grammar that has in-document > references (e.g. ref and define). I could just "flatten" the RNG but > I'd rather use the existing document. When I hit a ref in the RNG XML I > do this: > > <xsl:template match="ref"> > <li>Ref: > <b><xsl:value-of select="@name"/></b> > <ul> > <xsl:apply-templates > select="//define[@name=current()/@name]" > mode="def"/> > </ul> > </li> > </xsl:template> > > which kind of works, except for a big problem. The template rules that > are called by this are out of context. In other words, I want to treat > them as though they are children of the element "ref" but instead they > are treated as top-level elements in the XML file (which is true, of > course). > > How do I apply the templates and specify that the context should be the > current node? > > Sorry if this is a FAQ, I couldn't find it. > > Simon > > --- > www.simonwoodside.com > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] in-document references, S Woodside | Thread | RE: [xsl] in-document references, Martinez, Brian |
Re: [xsl] Hello and quick question, S Woodside | Date | Re: [xsl] in-document references, S Woodside |
Month |