RE: [xsl] How to reference nodes that have not yet been created ?

Subject: RE: [xsl] How to reference nodes that have not yet been created ?
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Sat, 18 Oct 2003 21:37:13 -0500
Hello Belangour,

I hope I understood your question right...

The short answer is, you can't reference nodes in the
result document (the stuff you're generating);
only in the source document.

However, there are ways to do what you're trying to do.

(1) If your data types are fixed, enter them as top-level
  elements of your stylesheet (they have to have a namespace).
  Then you can reference them from the stylesheet, and also
  copy them to your output document.

(2) Or, create a separate XML file containing your data types
  (either by hand, or by means of a separate stylesheet).
  Then use your datatypes XML document as the input document
  to your stylesheet (or get the data from it using document()

(3) Or use the node-set() extension to turn the result of the
  createDataTypes template into a node-set, which you can
  then reference.


> Hi all and thanks,
> How to reference nodes that have not yet been created (i.e 
> located on the
> xml file you want to generate)?
> Example:
>     I have an xsl program that creates datatypes at the 
> begining of the
> file. I     have then to reference them every time that i encounter a
> variable with     a given type.
> <xsl:template name="createDataTypes">
>      <dataType>
>        <xsl:attribute name="id"><xsl:value-of
> select="generate-id.)"/></xsl:attribute>
>        <xsl:attribute name="name">integer</xsl:attribute>
>      </dataType>
>         ...
> </xsl:template>
> <xsl:template match="myVariable">
>     <variable>
>         <xsl:attribute name="id"><xsl:value-of
> select="generate-id(.)"/></xsl:attribute>
>         <xsl:attribute name="name">integer</xsl:attribute>
>         <xsl:attribute name="type"><xsl:value-of
> select="#####getTypeID######"></xsl:attribute>
>      </variable>
>         ...
> </xsl:template>

 XSL-List info and archive:

Current Thread