xsl-list
[Top] [All Lists]

Re: [xsl] xslt 3.0 possible feature - some sort of collection to help when streaming

2011-03-10 14:03:10
Andrew,

This doesn't speak to the requirement itself (which seems perfectly legit to me), but only to the use case.

One approach to achieving the aims here is to reverse the order of operations. The first pass doesn't emit the messages, but simply generates elements in a namespace reserved for the purpose. The second pass strips them out, while emitting messages for them as it goes.

This approach works well when you are not set on using xsl:message as the reporting channel. For example, the messages can instead be siphoned to a separate document. Or, as you suggest, higher-level analysis of the message set can be conducted.

Needless to say, this is all a piece of cake in XSLT 2.0 with or without XProc. Or if you like, two pieces of cake.

Cheers,
Wendell

On 3/10/2011 1:28 PM, Andrew Welch wrote:
Often we 'hack' xsl:message to output some information to post process
later, and it struck me that it would be useful to have a way of
accessing what has been sent to xsl:message during the same transform.
  This would be especially useful when streaming, as processing the
data twice for different purposes is less than ideal.

For example, you for-each over some data but want to also do something
with @names later:

<xsl:for-each select="/millions/and/millions">

   [ process each item ]

   <xsl:message select="concat('Processed ', @name)"/>
</xsl:for-each>

then later in the same template, say to create an index or list of links:

<xsl:for-each select="get-messages()">
   [ process the items stored earlier 'Processed name1' , 'Processed name2' etc 
]

Is there anything conceptually wrong with this, other than the
non-guaranteed order of processing?  If not, then it could be a proper
instruction rather than xsl:message, eg a top-level element to set it
up:

<xsl:appender name="someAppender" option1="foo" option2="bar"/>

with:

<xsl:append name="someAppender">   text to append</xsl:append>

and then to access it:

get-appender('someAppender')



--
======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--