You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Paolo Audisio <se...@iperbole.bologna.it> on 2000/07/20 15:37:06 UTC

Xinclude... one more step...

Hello,
I have to generate an XML file selecting elements
from some other XML files.
I pass parameters in the url line: ../Ricerca.xml?find=item1
Xinclude works fine if I don't use any paramenter, like this:

<xinclude:include parse="xml"
href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='itemX'])"/>

but if I try to use the parameter "$find"

<xinclude:include parse="xml" 
href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key=$find])"/>

no way to make it working....

Calling an xsl file like this:
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xinclude="http://www.w3.org/1999/XML/xinclude" 
xmlns:xlink="http://www.w3.org/1999/xlink/namespace/">

  <xsl:param name="desc"/>
  <xsl:param name="find"/>

 <xsl:template match="/">

    <xsl:processing-instruction name="cocoon-process">
     type="xinclude"
    </xsl:processing-instruction>
    <xsl:processing-instruction name="xml-stylesheet">
      href="Ricerca2.xsl"
      type="text/xsl"
    </xsl:processing-instruction>

   <xsl:processing-instruction name="cocoon-process">
     type="xslt"
   </xsl:processing-instruction>

  <xsl:element name="Sala">
  
  <xsl:element name="Sector">
   <xsl:attribute name="descr">Finding the keyword '<xsl:value-of select="$find" />'</xsl:attribute
>

     <xsl:element name="xinclude:include">
      <xsl:attribute name="parse">xml</xsl:attribute>
      <xsl:attribute name="href">Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='<xsl:value-
of select="$find" />'])</xsl:attribute>
     </xsl:element>

  </xsl:element>
  </xsl:element>

 </xsl:template>

</xsl:stylesheet>
 
I obtain this intermediate file:
--------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<Pagina xmlns:xinclude="http://www.w3.org/1999/XML/xinclude"
xmlns:xlink="http://www.w3.org/1999/xlink/namespace/">
<Sala>
<Sector descr="Finding the keyword 'item1'">
<xinclude:include href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='item1'])" parse="xml
">
</xinclude:include>
</Sector></Sala></Pagina>

<!-- This page was served from cache in 88 milliseconds by Cocoon 1.7.5-dev -->
-------------------------------------------------------------------------------

but XInclude elements are not resolved.... I need to make this processed
again by xinclude, but I don't know how... I tried with XSP too, but the
file I obtain, again, is with unresolved XInclude elements...

I really don't know how to make it...
Any idea?

Thank you very much!
Paolo


Re: Xinclude... one more step...

Posted by Paolo Audisio <se...@iperbole.bologna.it>.
On 20 Jul 2000, at 17:44, Donald Ball wrote:

> > I obtain this intermediate file:
> > --------------------------------
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
> > <Pagina xmlns:xinclude="http://www.w3.org/1999/XML/xinclude"
> > xmlns:xlink="http://www.w3.org/1999/xlink/namespace/">
> > <Sala>
> > <Sector descr="Finding the keyword 'item1'">
> > <xinclude:include href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='item1'])" parse="xml
> > ">
> > </xinclude:include>
> > </Sector></Sala></Pagina>
> 
> as you see, this purports to be an HTML file, not XML - the PIs that you
> created aren't there. add the <?cocoon-format type="text/xml"?> PI and all
> should be well.

Donald, i put this PI everywhere, in the XML file, in the XSL, in various
position, but all what i get is the same HTML file....
Where, exactly, have I to put it ?
I'm actually using cocoon 1.7.5-dev, may be I've to upgrade ?


> btw, so long as you're doing the include from an XSLT stylesheet, you may
> as well simply use the document() function to include the nodes you're
> interested in.

I'm not sure if it's OK for me, because I've to do some further elaborations,
but I'm going to study it!

Thank you!
Paolo


Re: Xinclude... one more step...

Posted by Ulrich Mayring <ul...@denic.de>.
Donald Ball wrote:
> 
> On Fri, 21 Jul 2000, Uli Mayring wrote:
> 
> > This reminds me to ask if you have used the patch I posted a few days ago
> > to enable absolute URIs in XInclude's href attribute?
> 
> er, i may have missed it in my sick haze? flip it my way again. (i'd
> thought my most recent set of patches made absolute URI's work though...)

I just checked out the newest cocoon dev snapshot and see that absolute
URLs work now. It seems you missed my bugfix and I missed your
announcement that it was fixed :-)

Thanks a lot Donald.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

Re: Xinclude... one more step...

Posted by Donald Ball <ba...@webslingerZ.com>.
On Fri, 21 Jul 2000, Uli Mayring wrote:

> On Thu, 20 Jul 2000, Donald Ball wrote:
> 
> > can't do that. xinclude/xpointer lets you use xpath expressions, but
> > there's no variable context.
> 
> This reminds me to ask if you have used the patch I posted a few days ago
> to enable absolute URIs in XInclude's href attribute?

er, i may have missed it in my sick haze? flip it my way again. (i'd
thought my most recent set of patches made absolute URI's work though...)

- donald


Re: Xinclude... one more step...

Posted by Uli Mayring <ul...@denic.de>.
On Thu, 20 Jul 2000, Donald Ball wrote:

> can't do that. xinclude/xpointer lets you use xpath expressions, but
> there's no variable context.

This reminds me to ask if you have used the patch I posted a few days ago
to enable absolute URIs in XInclude's href attribute?

Ulrich

-- 
Ulrich Mayring
DENIC eG, Softwareentwicklung


Re: Xinclude... one more step...

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 20 Jul 2000, Paolo Audisio wrote:

> Hello,
> I have to generate an XML file selecting elements
> from some other XML files.
> I pass parameters in the url line: ../Ricerca.xml?find=item1
> Xinclude works fine if I don't use any paramenter, like this:
> 
> <xinclude:include parse="xml"
> href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='itemX'])"/>
> 
> but if I try to use the parameter "$find"
> 
> <xinclude:include parse="xml" 
> href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key=$find])"/>

can't do that. xinclude/xpointer lets you use xpath expressions, but
there's no variable context.

> Calling an xsl file like this:
> ------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> xmlns:xinclude="http://www.w3.org/1999/XML/xinclude" 
> xmlns:xlink="http://www.w3.org/1999/xlink/namespace/">
> 
>   <xsl:param name="desc"/>
>   <xsl:param name="find"/>
> 
>  <xsl:template match="/">
> 
>     <xsl:processing-instruction name="cocoon-process">
>      type="xinclude"
>     </xsl:processing-instruction>
>     <xsl:processing-instruction name="xml-stylesheet">
>       href="Ricerca2.xsl"
>       type="text/xsl"
>     </xsl:processing-instruction>
> 
>    <xsl:processing-instruction name="cocoon-process">
>      type="xslt"
>    </xsl:processing-instruction>
> 
>   <xsl:element name="Sala">
>   
>   <xsl:element name="Sector">
>    <xsl:attribute name="descr">Finding the keyword '<xsl:value-of select="$find" />'</xsl:attribute
> >
> 
>      <xsl:element name="xinclude:include">
>       <xsl:attribute name="parse">xml</xsl:attribute>
>       <xsl:attribute name="href">Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='<xsl:value-
> of select="$find" />'])</xsl:attribute>
>      </xsl:element>
> 
>   </xsl:element>
>   </xsl:element>
> 
>  </xsl:template>
> 
> </xsl:stylesheet>
 
> I obtain this intermediate file:
> --------------------------------
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
> <Pagina xmlns:xinclude="http://www.w3.org/1999/XML/xinclude"
> xmlns:xlink="http://www.w3.org/1999/xlink/namespace/">
> <Sala>
> <Sector descr="Finding the keyword 'item1'">
> <xinclude:include href="Sala1n.xml#xpointer(Sala/Sector/Resource[KeyWords/Key='item1'])" parse="xml
> ">
> </xinclude:include>
> </Sector></Sala></Pagina>

as you see, this purports to be an HTML file, not XML - the PIs that you
created aren't there. add the <?cocoon-format type="text/xml"?> PI and all
should be well.

btw, so long as you're doing the include from an XSLT stylesheet, you may
as well simply use the document() function to include the nodes you're
interested in.

- donald