Re: [xsl] Need to render input document as string form of XML in output

Subject: Re: [xsl] Need to render input document as string form of XML in output
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Tue, 11 Sep 2012 14:34:48 +0200
In this posting you can find a XSLT 1.0 serializer:
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201008/msg00186.html

The comments from Martin and David in that thread showed that my solution
was 10 years late ;-)


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team and Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
https://twitter.com/#!/HermannSW/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


|------------>
| From:      |
|------------>
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
  |Chris Wolf <cwolf.algo@xxxxxxxxx>                                                                                                              |
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
  |xsl-list@xxxxxxxxxxxxxxxxxxxxxx,                                                                                                               |
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
  |09/11/2012 01:02 AM                                                                                                                            |
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >-----------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: [xsl] Need to render input document as string form of XML in output                                                                        |
  >-----------------------------------------------------------------------------------------------------------------------------------------------|





Michael,

Believe me, I'm trying to get Saxon in, but for now, we're stuck with
the old Xalan (I think 2.7.2) that's repackaged into the
Sun (Oracle) JRE...

So there is some explicit serialization required?  I guess I'll have
to write some complicated recursive template to
do it...  (another issue is that we're running within JBossAS and
Xalan extensions don't seem to work due to classloader Hell)

   -Chris

P.S. thanks for the quick reply...


On Mon, Sep 10, 2012 at 6:22 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> If you're using Saxon, you could do
>
> <xsl:value-of select="saxon:serialize(/*)"/>
>
> Michael Kay
> Saxonica
>
>
> On 10/09/2012 22:33, Chris Wolf wrote:
>>
>> Hello,
>>
>> Before I start my question - I searched all over the Internet,
>> including the XLS-FAQ and the archives of this list and could find
>> nothing.
>>
>> I have a transform with output method="text".   In addition to
>> rendering the results of the transform, I'd like to append a readable
>> string version of the input document XML to the end of the
>> transformation result.
>>
>> I tried declaring a top-level variable like so
>>
>> <xsl:variable name="inputDoc" select="/*"/>
>>
>> Then at the end of my default template:
>>
>> <xsl:value-of select="$inputDoc"/>
>>
>> But this only renders the text of text nodes, not element and attribute
>> names.
>>
>> I then tried:
>>
>> <xsl:value-of select="string($inputDoc)"/>
>>
>> ...but I guess that just make explicit what already occurs implicitly,
>> since I got the same results.
>>
>> One of my web search hits, some guy was taking about a serializer
>> extension, or something like that - surely I don't
>> need to resort to that, do I?
>>
>> Do I need to implement some kind of recursive template that explicity
>> calls name() on elements and attributes?
>>
>> Since my output is type text, I'm guessing the solution would involve
>> @disable-output-escaping="true", unless I decide
>> I want output method="html".
>>
>> Thanks,
>>
>> Chris Wolf

Current Thread