Re: [xsl] How to incrementally add to a result document?

Subject: Re: [xsl] How to incrementally add to a result document?
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Jun 2024 22:55:24 -0000
Alternatively, one could create a separate result-document (with different
name) for every log entry and write these result-documents in a specially -
dedicated to the transformation "log-directory".

One could probably hope that in the event of an error that causes the
transformation to be aborted, the log entries for the work that has already
been done, will be there - residing in the log-directory.

Also, if the sequence of log-entries is huge to maintain in memory, this
alternative approach may work like output-streaming.

Thanks,
Dimitre

On Fri, Jun 28, 2024 at 3:39b/PM Dimitre Novatchev dnovatchev@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> I would represent the log as a global map variable and place any action
> there as an entry like  {action-key, action-info}, immediately on
> completing each action.
>
> Finally, when the processing is finished, we can produce  from  the
> log-map  a single result-document that contains all entries of the log-map.
>
> Thanks,
> Dimitre
>
> On Fri, Jun 28, 2024 at 2:38b/PM Roger L Costello costello@xxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> Hi Folks,
>>
>> I have an XSLT program that converts an old form to a new form. My XSLT
>> program has a template rule that converts this old form:
>>
>> <Airport_Name>Boston Logan Airport</Airport_Name>
>>
>> to this new form:
>>
>> <name>Boston Logan Airport</name>
>>
>> My XSLT program has a template rule that converts this old form:
>>
>> <Airport_Elevation>19</Airport_Elevation>
>>
>> to this new form:
>>
>> <elevation>19</elevation>
>>
>> I want the template rules to also output -- to another, different file --
>> metadata that shows what actions were taken. Here is the template rule for
>> Airport_Name:
>> -----------------------------------------------------------
>> <xsl:template match="Airport_Name">
>>     <name>
>>         <xsl:value-of select="normalize-space(.)"/>
>>     </name>
>>     <!-- output metadata showing the actions taken -->
>>     <xsl:result-document href="metadata.xml" format="XML-format">
>>         <mapping>
>>             <legacy-elmt-name>
>>                 <xsl:value-of select="name()"/>
>>             </legacy-elmt-name>
>>             <legacy-elmt-value>
>>                 <xsl:value-of select="."/>
>>             </legacy-elmt-value>
>>             <new-elmt-name>
>>                 <xsl:text>name</xsl:text>
>>             </new-elmt-name>
>>             <new-elmt-value>
>>                 <xsl:value-of select="normalize-space(.)"/>
>>             </new-elmt-value>
>>         </mapping>
>>     </xsl:result-document>
>> </xsl:template>
>> -----------------------------------------------------------
>> Here is the template rule for Airport_Elevation:
>> -----------------------------------------------------------
>> <xsl:template match="Airport_Elevation">
>>     <elevation>
>>         <xsl:if test=". castable as xs:integer">
>>             <xsl:value-of select="xs:integer(.)"/>
>>         </xsl:if>
>>     </elevation>
>>     <!-- output metadata showing the actions taken -->
>>     <xsl:result-document href="metadata.xml" format="XML-format">
>>         <mapping>
>>             <legacy-elmt-name>
>>                 <xsl:value-of select="name()"/>
>>             </legacy-elmt-name>
>>             <legacy-elmt-value>
>>                 <xsl:value-of select="."/>
>>             </legacy-elmt-value>
>>             <new-elmt-name>
>>                 <xsl:text>elevation</xsl:text>
>>             </new-elmt-name>
>>             <new-elmt-value>
>>                 <xsl:if test=". castable as xs:integer">
>>                     <xsl:value-of select="xs:integer(.)"/>
>>                 </xsl:if>
>>             </new-elmt-value>
>>         </mapping>
>>     </xsl:result-document>
>> </xsl:template>
>> -----------------------------------------------------------
>> Here is how the template rules are activated:
>>
>> <airport>
>>         <xsl:apply-templates select="Airport_Name"/>
>>         <xsl:apply-templates select="Airport_Elevation"/>
>> </airport>
>>
>> When I run my XSLT program I get this error message:
>>
>> Error in xsl:result-document/@href
>> XTDE1490  Cannot write more than one result document to the same URI
>>
>> The error message is telling me that I cannot write to the metadata.xml
>> file in an incremental fashion, right?
>>
>> What to do?
>>
>> Is there anyway that I can achieve what I desire -- output to one
>> document the result of mapping the old form to the new form and output to
>> another document metadata that describes the mapping steps that were
taken?
>> Or is this outside the realm of XSLT's capabilities?
>>
>> /Roger
>>
>>
>>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by
> email <>)

Current Thread