xsl-list
[Top] [All Lists]

Re: Perpetuating xsl instructions

2003-05-13 09:42:44
Hi Alan,

The solution requires dynamically writing a web page by aggregating
n number of XML docs without writing any code (a one off solution).
Essentially a chain reaction is initiated where the first XSL
document runs up a 'tree' of XML documents, merging XML into itself.
The terminating transformation results in a pure XML document (minus
the XSL) with all the content needed to build the web page.

If you can think of another solution, we'd love to hear it.

I'll take a wild stab in the dark and guess that your documents look
like:

<foo>
  <bar />
  <include href="doc1.xml" />
</foo>

and you want the content of doc1.xml to replace the <include> element
with, naturally, doc1.xml containing its own <include> elements that
need to be replaced and so on.

If that's the case, then you need a stylesheet based on an identity
transformation (one that just copies the content of the document,
recursively):

<xsl:template match="node()|@*">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()" />
  </xsl:copy>
</xsl:template>

where <include> elements are treated specially, by applying templates
to the referenced document (retrieved using the document() function):

<xsl:template match="include">
  <xsl:apply-templates select="document(@href, .)/*" />
</xsl:template>

Of course it might be that I'm way off the mark. If you want something
more helpful, I really recommend that you put together a short example
that shows what your documents look like and what the final result you
want looks like. Without that information, it is really hard for us to
give you any advice.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list