[xsl] Re: Recursively link XML blocks (other)

Subject: [xsl] Re: Recursively link XML blocks (other)
From: Costantino_Sertorio@xxxxxxxxxx
Date: Tue, 27 Nov 2001 18:41:25 +0100

Thank you very much for your answer,
actually I already solved that problem, thanks to the great help of a number of
this list's subscribers (this is a great list!!).
To answer your curiosity, I'm trying to develop a "recursive document
generator". The  purpose is to store text "blocks" that will call each other,
and use them to automatically generate letters and other documents, that will be
feeded to a number of "end users". This will minimize redundancy in the document
"database".
There are a number of open issues for this: for example, the letters will have
to be modifiable after they are created.
Some ideas to solve this were:
- generate PDF (not modifiable unless by installing Acrobat), or
- generate FO and then produce RTF with JFOR (but this tool is not mature
enough), or
- generate a "flat" (non-recursive) XML and feed it to another "old-style"
program written in some other language like VB, which then generates a Word
document, or still
- generate the "flat" XML file and let the end user edit it directly, but in
order not to risk errors, the end user would have to use some strong and
supersimple WYSIWYG XML editor.

But unfortunately this will probably be out of the scope of this list!
Thank you again, and thanks to all the people that helped me with my previous
problem.

Costantino



|--------+----------------------->
|        |          philippe drix|
|        |          <phdrix@free.|
|        |          fr>          |
|        |                       |
|        |          26.11.01     |
|        |          21:47        |
|        |                       |
|--------+----------------------->
  >----------------------------------------------------------------------------|
  |                                                                            |
  |       To:     Costantino Sertorio/AMS/AMSINC@AMSINC                        |
  |       cc:                                                                  |
  |       Subject:     Recursively link XML blocks (other)                     |
  >----------------------------------------------------------------------------|




Hello Costantino,
I have subsribed to the XSL-LIST DIGEST only, but however, I received
yesterday your post on XSLT mailing-list in my mail box, I don't know why.
I have replied to your question, but I don't know if I am granted to do
so, because I am not a plain XSL-MAILING  LIST subscriber.

Here my solution :


Costantino_Sertorio@xxxxxxxxxx wrote:
>
> Hello everybody,
> I am trying (without success, at the moment...) to do the following:
>
> XML document:
> ...
> <element_A>
>      textA textA textA
>      <insert>element_B</insert>
>      textA textA textA
> </element_A>
>
> <element_B>
>      textB textB textB
>      <insert>element_C</insert>
>      textB textB textB
> </element_B>
>
> <element_C>
>      textC textC textC
>      textC textC textC
> </element_C>
> ....etc.
>
> Desired output:
>      textA textA textA
>      textB textB textB
>      textC textC textC
>      textC textC textC
>      textB textB textB
>      textA textA textA
>

Hello,
try this :
<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    version="1.0">

    <xsl:output  method='text'  encoding='ISO-8859-1' />


    <xsl:template match="/">
        <xsl:call-template name="make_insert">
                <xsl:with-param name="elem" select="'element_A'" />
        </xsl:call-template>
    </xsl:template>


    <xsl:template match="insert">
        <xsl:call-template name="make_insert">
                <xsl:with-param name="elem" select="." />
        </xsl:call-template>
    </xsl:template>


    <xsl:template name="make_insert">
        <xsl:param name="elem"/>
        <xsl:for-each select="//*[name() = $elem ]" >
                <xsl:value-of select="./child::text()[1]"/>
                <xsl:apply-templates/>
                <xsl:value-of select="./child::text()[2]"/>
        </xsl:for-each>
    </xsl:template>



    <xsl:template match="text()"/>

</xsl:stylesheet>


Right now, I am writing a book on XSLT (in French ...), and I found your
question very interesting, but I wonder in which real context you met
this sort of problem ?

Regards,
Philippe Drix
www.objectiva.fr





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


Current Thread