You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lincoln <li...@oracle.com> on 2006/01/05 04:30:43 UTC

sourcefragment

How do I get source:fragment in SourceWritingTransformer to contain:

1. A document on the file system. I have tried:
<source:fragment>
  <xi:include href="rect.svg" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</source:fragment>

and I tied...

<source:fragment>
  <xsl:value-of select="document(rect.svg)"/>
</source:fragment>


2. A xml nodeset at run time. I have tried
<source:fragment>
  <xsl:value-of select="$mySvg"/>
</source:fragment>


Currently I can only write a file to the file system if its pasted inside
<source:fragment>
  <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
    <rect width="100" height="100" />
  </svg>
</source:fragment>


Any help appreciated.

Linc



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: sourcefragment

Posted by Lincoln <li...@oracle.com>.
Whoops! I believe I incorrectly assigned the variable with a string rather
than a nodeSet. Correction:
--
<source:fragment>
  <xsl:variable name="svg"
select="xalan:evaluate('&lt;svg&gt;&lt;/svg&gt;')"/>
  <xsl:copy-of select="$svg"/>
</source:fragment>
---


Linc



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: sourcefragment

Posted by Lincoln <li...@oracle.com>.
Ran XIncludeTransformer before the SourceWritingTransformer as you mentioned
and works a treat! Thx a million.

I am now trying copy-of as follows:
<source:fragment>
  <xsl:variable name="svg" select="'&lt;svg&gt;&lt;/svg&gt;'"/>
  <xsl:copy-of select="$svg"/>
</source:fragment>

...But get a "java.lang.NullPointerException" Failed to process pipeline
error. 

I am only assigning the xml to a variable here to see if copy-of will work.
Is that the problem? Are variables definitions not allowed here.

Linc

> -----Original Message-----
> From: Jason Johnston [mailto:cocoon@lojjic.net]
> Sent: Thursday, January 05, 2006 1:56 PM
> To: users@cocoon.apache.org
> Subject: Re: sourcefragment
> 
> Lincoln wrote:
> > How do I get source:fragment in SourceWritingTransformer to contain:
> >
> > 1. A document on the file system. I have tried:
> > <source:fragment>
> >   <xi:include href="rect.svg"
> xmlns:xi="http://www.w3.org/2001/XInclude"/>
> > </source:fragment>
> 
> It seems like this should work, as long as you have the
> XIncludeTransformer run before the SourceWritingTransformer in your
> pipeline so the xi:include gets expanded.
> 
> >
> > and I tied...
> >
> > <source:fragment>
> >   <xsl:value-of select="document(rect.svg)"/>
> > </source:fragment>
> >
> >
> > 2. A xml nodeset at run time. I have tried
> > <source:fragment>
> >   <xsl:value-of select="$mySvg"/>
> > </source:fragment>
> 
> Neither of these will work because xsl:value-of only writes out the
> descendant text nodes.  xsl:copy-of should work better.
> 
> > Currently I can only write a file to the file system if its pasted
> inside
> > <source:fragment>
> >   <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
> >     <rect width="100" height="100" />
> >   </svg>
> > </source:fragment>
> 
> If you place a <map:serialize type="xml"/> directly before the
> SourceWritingTransformer stage (or use a cocoon view) it will show you
> what that transformer is getting as input.  It should look the same
> whether it comes from the source XML or an XInclude etc. so this will
> allow you to verify that.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: sourcefragment

Posted by Jason Johnston <co...@lojjic.net>.
Lincoln wrote:
> How do I get source:fragment in SourceWritingTransformer to contain:
> 
> 1. A document on the file system. I have tried:
> <source:fragment>
>   <xi:include href="rect.svg" xmlns:xi="http://www.w3.org/2001/XInclude"/>
> </source:fragment>

It seems like this should work, as long as you have the 
XIncludeTransformer run before the SourceWritingTransformer in your 
pipeline so the xi:include gets expanded.

> 
> and I tied...
> 
> <source:fragment>
>   <xsl:value-of select="document(rect.svg)"/>
> </source:fragment>
> 
> 
> 2. A xml nodeset at run time. I have tried
> <source:fragment>
>   <xsl:value-of select="$mySvg"/>
> </source:fragment>

Neither of these will work because xsl:value-of only writes out the 
descendant text nodes.  xsl:copy-of should work better.

> Currently I can only write a file to the file system if its pasted inside
> <source:fragment>
>   <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
>     <rect width="100" height="100" />
>   </svg>
> </source:fragment>

If you place a <map:serialize type="xml"/> directly before the 
SourceWritingTransformer stage (or use a cocoon view) it will show you 
what that transformer is getting as input.  It should look the same 
whether it comes from the source XML or an XInclude etc. so this will 
allow you to verify that.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org