XInclude with parse="text"

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

XInclude with parse="text"

Damiano Albani-2
Hello,

I have a bunch of XQuery functions that are used in several .xpl model
files. So I tried to XInclude them in the XSLT processor, specifying
parse="text" as it's not XML but simple text.

  ERROR: Invalid 'parse' attribute value: text

So I headed to XSL 2.0, using the unparsed-text() function in
<xsl:value-of/>. But it wasn't really better...

  ERROR: unknown protocol: oxf

What should I do then ?

Cheers,

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
Dominic,
        In the XQuery file, place a tag around all the text, something like
<document> then when you import it, just use value-of to print it.

Ryan

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 30 March 2006 13:20
>To: [hidden email]
>Subject: [ops-users] XInclude with parse="text"
>
>Hello,
>
>I have a bunch of XQuery functions that are used in several .xpl model
>files. So I tried to XInclude them in the XSLT processor, specifying
>parse="text" as it's not XML but simple text.
>
>  ERROR: Invalid 'parse' attribute value: text
>
>So I headed to XSL 2.0, using the unparsed-text() function in
><xsl:value-of/>. But it wasn't really better...
>
>  ERROR: unknown protocol: oxf
>
>What should I do then ?
>
>Cheers,
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
On 3/30/06, Ryan Puddephatt <[hidden email]> wrote:
> Dominic,
>         In the XQuery file, place a tag around all the text, something like
> <document> then when you import it, just use value-of to print it.

That does work correctly, thanks for the tip !
So now, more difficult : how could I include/import a single file,
which would in turn include/import several (text) files ? I don't
*absolutely* need this feature but that would be nice though.
I've thought a bit about it but I find no solution. Even with
XInclude, this wouldn't work, as the root element of the "main" file
would be carried over in the final result. No?

Still, is the behavior of OPS, as I described in my first message,
correct and compliant with the XInclude/XSL 2.0 standards ? Or are
they bugs or known limitations ?

Cheers,

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
Dominic,
Create an XSL file with all the imports in it, then import that file!

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 30 March 2006 14:08
>To: [hidden email]
>Subject: Re: [ops-users] XInclude with parse="text"
>
>On 3/30/06, Ryan Puddephatt <[hidden email]> wrote:
>> Dominic,
>>         In the XQuery file, place a tag around all the text, something
>like
>> <document> then when you import it, just use value-of to print it.
>
>That does work correctly, thanks for the tip !
>So now, more difficult : how could I include/import a single file,
>which would in turn include/import several (text) files ? I don't
>*absolutely* need this feature but that would be nice though.
>I've thought a bit about it but I find no solution. Even with
>XInclude, this wouldn't work, as the root element of the "main" file
>would be carried over in the final result. No?
>
>Still, is the behavior of OPS, as I described in my first message,
>correct and compliant with the XInclude/XSL 2.0 standards ? Or are
>they bugs or known limitations ?
>
>Cheers,
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
On 3/30/06, Ryan Puddephatt <[hidden email]> wrote:
> Dominic,
> Create an XSL file with all the imports in it, then import that file!

Sorry, but I don't really see how to do it. Could you give me an example ?

Cheers,

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
Dominic,
        Lets say you have a file call allImports.xsl. this contains

<xsl:stylsheet xmlns:xsl="http://www.w3.org/1999/XML/Transform"
version="2.0">
        <xsl:variable name="import1" href="doc('import1.xml')"/>
        <xsl:variable name="import2" href="doc('import2.xml')"/>
        <xsl:variable name="import3" href="doc('import3.xml')"/>
        <xsl:variable name="import4" href="doc('import4.xml')"/>
        <xsl:variable name="import5" href="doc('import5.xml')"/>
</xsl:stylesheet>

Then you can do

<xsl:import href="allImports.xsl"/>

Which will give you all those variables so you can just do

<xsl:value-of select="$import1/rootElement"/>

You could put "rootElement" in the variable so you can just call $import1
instead of $import1/rootElement

Hope this helps

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 31 March 2006 10:37
>To: [hidden email]
>Subject: Re: [ops-users] XInclude with parse="text"
>
>On 3/30/06, Ryan Puddephatt <[hidden email]> wrote:
>> Dominic,
>> Create an XSL file with all the imports in it, then import that file!
>
>Sorry, but I don't really see how to do it. Could you give me an example ?
>
>Cheers,
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
Ryan,

I did as you told me, so in my model .xpl I have :

  <p:processor name="oxf:xslt">
    <p:input name="data" href="#instance"/>
    <p:input name="config">
      <xdb:query collection="/db/TransFranceInfo" xsl:version="2.0">
        <xsl:import href="includeXQuery.xsl"/>
        <!-- includeXQuery.xsl declare import* variables -->

        <xsl:value-of select="$import1"/>
        <xsl:value-of select="$import2"/>

        <!-- here my XQuery -->

      </xdb:query>
    </p:input>
    <p:output name="data" id="query" debug="true"/>
  </p:processor>

  <p:processor name="oxf:xmldb-query">
    <p:input name="datasource" href="../datasource.xml"/>
    <p:input name="query" href="#query"/>
    <p:output name="data" ref="data" debug="true"/>
  </p:processor>


Unfortunately, I have an error saying that $import1 is an unknown variable.
So where's my mistake ? I must (again) have missed something :-)

Cheers,

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
What does includeXQuery.xsl look like?

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 31 March 2006 13:17
>To: [hidden email]
>Subject: Re: [ops-users] XInclude with parse="text"
>
>Ryan,
>
>I did as you told me, so in my model .xpl I have :
>
>  <p:processor name="oxf:xslt">
>    <p:input name="data" href="#instance"/>
>    <p:input name="config">
>      <xdb:query collection="/db/TransFranceInfo" xsl:version="2.0">
>        <xsl:import href="includeXQuery.xsl"/>
>        <!-- includeXQuery.xsl declare import* variables -->
>
>        <xsl:value-of select="$import1"/>
>        <xsl:value-of select="$import2"/>
>
>        <!-- here my XQuery -->
>
>      </xdb:query>
>    </p:input>
>    <p:output name="data" id="query" debug="true"/>
>  </p:processor>
>
>  <p:processor name="oxf:xmldb-query">
>    <p:input name="datasource" href="../datasource.xml"/>
>    <p:input name="query" href="#query"/>
>    <p:output name="data" ref="data" debug="true"/>
>  </p:processor>
>
>
>Unfortunately, I have an error saying that $import1 is an unknown variable.
>So where's my mistake ? I must (again) have missed something :-)
>
>Cheers,
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
includeXQuery.xsl contains :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xsl:version="2.0">

  <xsl:variable name="import1"
select="unparsed-text('xql/namespaces.xql', 'UTF-8')"/>
  <xsl:variable name="import2"
select="unparsed-text('xql/functions.xql', 'UTF-8')"/>

</xsl:stylesheet>

I also tried with :

  <xsl:variable name="import1" select="doc('xql/namespaces.xql')/root"/>
  <xsl:variable name="import2" select="doc('xql/functions.xql')/root"/>

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
Dominic, try changing the variables to <xsl:import>s then all you will have
to do is the <xsl:import> on the query

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 31 March 2006 13:48
>To: [hidden email]
>Subject: Re: [ops-users] XInclude with parse="text"
>
>includeXQuery.xsl contains :
>
><?xml version="1.0" encoding="UTF-8"?>
><xsl:stylesheet xmlns="http://www.w3.org/1999/XSL/Transform"
>xsl:version="2.0">
>
>  <xsl:variable name="import1"
>select="unparsed-text('xql/namespaces.xql', 'UTF-8')"/>
>  <xsl:variable name="import2"
>select="unparsed-text('xql/functions.xql', 'UTF-8')"/>
>
></xsl:stylesheet>
>
>I also tried with :
>
>  <xsl:variable name="import1" select="doc('xql/namespaces.xql')/root"/>
>  <xsl:variable name="import2" select="doc('xql/functions.xql')/root"/>
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
On 3/31/06, Ryan Puddephatt <[hidden email]> wrote:
> Dominic, try changing the variables to <xsl:import>s then all you will have
> to do is the <xsl:import> on the query

Which means all the files I <xsl:import> must be stylesheets and not
plain text files as I want, doesn't it ? Or then I have to enclose my
text files in a stylesheet ???
It looks like we're going in an infinite loop :-)

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
Ok why not do

<document xsl:version="2.0">
        <xsl:value-of select="doc('import1.xql')"/>
        <xsl:value-of select="doc('import2.xql')"/>
</document>

In the xsl to import, then just

<xsl:value-of select="doc('allImports.xsl')/document"/>

That should work

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 31 March 2006 15:31
>To: [hidden email]
>Subject: Re: [ops-users] XInclude with parse="text"
>
>On 3/31/06, Ryan Puddephatt <[hidden email]> wrote:
>> Dominic, try changing the variables to <xsl:import>s then all you will
>have
>> to do is the <xsl:import> on the query
>
>Which means all the files I <xsl:import> must be stylesheets and not
>plain text files as I want, doesn't it ? Or then I have to enclose my
>text files in a stylesheet ???
>It looks like we're going in an infinite loop :-)
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
On 3/31/06, Ryan Puddephatt <[hidden email]> wrote:

> Ok why not do
>
> <document xsl:version="2.0">
>         <xsl:value-of select="doc('import1.xql')"/>
>         <xsl:value-of select="doc('import2.xql')"/>
> </document>
>
> In the xsl to import, then just
>
> <xsl:value-of select="doc('allImports.xsl')/document"/>
>
> That should work
Unfortunately, it doesn't -- at least not as I want.
What gets imported with <xsl:value-of
select="doc('allImports.xsl')/document"/> is the text content of the
"document" element but not its other children.
For example, if I write :

<document xsl:version="2.0">
        My text here !!
        <xsl:value-of select="doc('import1.xql')"/>
        <xsl:value-of select="doc('import2.xql')"/>
</document>

only the string "My text here !!" is imported in as a result :-/
I find "funny" how difficult it is to just emulate a basic C-like #include...

Thanks Ryan for all the time your devote to my problem by the way !

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: XInclude with parse="text"

Ryan Puddephatt
<xsl:copy-of select="doc('doc.xsl')/document/*"/>

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Damiano Albani [mailto:[hidden email]]
>Sent: 31 March 2006 22:28
>To: [hidden email]
>Subject: Re: [ops-users] XInclude with parse="text"
>
>On 3/31/06, Ryan Puddephatt <[hidden email]> wrote:
>> Ok why not do
>>
>> <document xsl:version="2.0">
>>         <xsl:value-of select="doc('import1.xql')"/>
>>         <xsl:value-of select="doc('import2.xql')"/>
>> </document>
>>
>> In the xsl to import, then just
>>
>> <xsl:value-of select="doc('allImports.xsl')/document"/>
>>
>> That should work
>
>Unfortunately, it doesn't -- at least not as I want.
>What gets imported with <xsl:value-of
>select="doc('allImports.xsl')/document"/> is the text content of the
>"document" element but not its other children.
>For example, if I write :
>
><document xsl:version="2.0">
>        My text here !!
>        <xsl:value-of select="doc('import1.xql')"/>
>        <xsl:value-of select="doc('import2.xql')"/>
></document>
>
>only the string "My text here !!" is imported in as a result :-/
>I find "funny" how difficult it is to just emulate a basic C-like
>#include...
>
>Thanks Ryan for all the time your devote to my problem by the way !
>
>--
>Damiano ALBANI




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
On 4/1/06, Ryan Puddephatt <[hidden email]> wrote:
> <xsl:copy-of select="doc('doc.xsl')/document/*"/>

It then only imports the non-processed content of the stylesheet. So
the output of oxf:xslt is for example :

<xdb:query collection="/db/TransFranceInfo">
    <xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
select="doc(&apos;xql/namespaces.xql&apos;)/root"/>
    <xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
select="doc(&apos;xql/functions.xql&apos;)/root"/>

  let a := "b";
...

</xdb:query>

Now if it could evaluate (again) those <xsl:value-of/>, it would work.
For the moment, I resigned myself to use directly the list of
<xsl:value-of select="doc('...')"/> as I have only a few different
XQuery fragments to include.

By the way, I tried to use the XSLT 2.0 unparsed-text() function but
it didn't work either ("unknown protocol: oxf").
Now if he had a top-notch XInclude support, that would help :-)

Cheers,

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Alessandro  Vernet
Administrator
On 4/1/06, Damiano Albani <[hidden email]> wrote:
> By the way, I tried to use the XSLT 2.0 unparsed-text() function but
> it didn't work either ("unknown protocol: oxf").
> Now if he had a top-notch XInclude support, that would help :-)

Hi Damiano,

This is what one calls a long thread :). Would care to summarize what
the outstanding issues are at this point with XSLT unparsed-text() and
XInclude?

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Damiano Albani-2
On 4/4/06, Alessandro Vernet <[hidden email]> wrote:
>
> Hi Damiano,
>
> This is what one calls a long thread :). Would care to summarize what
> the outstanding issues are at this point with XSLT unparsed-text() and
> XInclude?
>
> Alex

Well, as I said in my first message in this thread :

 1/ at the moment, XInclude in OPS doesn't support importing text
documents (parse="text"), so I had to resort to using XSLT...

 2/ ...XSLT, which seems to have issues with 2.0 unparsed-text()
function : error "unknown protocol: oxf"" is triggered.

So, at the end, instead of XInclude or XSLT's unparsed-text(), I used
basic <xsl:value-of select="doc(...)/root"/>, which means I had to
"convert" my text files to valid XML, i.e. add a root element. And
I've got to repeat the whole list of files everywhere I want to
include them, instead of having a single, central file to include
(which would in turn includes all the others).

In conclusion, I find surprisingly difficult to "simply" include text
files... :-)

What do you think ?

--
Damiano ALBANI



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XInclude with parse="text"

Alessandro  Vernet
Administrator
Hi Damiano,

On 4/5/06, Damiano Albani <[hidden email]> wrote:
>  1/ at the moment, XInclude in OPS doesn't support importing text
> documents (parse="text"), so I had to resort to using XSLT...

Right. This is a known and documented limitation, but I added a bug
for this nevertheless.

http://forge.objectweb.org/tracker/index.php?func=detail&aid=304935&group_id=168&atid=350207

>  2/ ...XSLT, which seems to have issues with 2.0 unparsed-text()
> function : error "unknown protocol: oxf"" is triggered.

We plug our own URI listener so we get a change to resolve URIs like
oxf:/... but it does not get called in this case. I created a bug for
this.

http://forge.objectweb.org/tracker/index.php?func=detail&aid=304936&group_id=168&atid=350207

> In conclusion, I find surprisingly difficult to "simply" include text
> files... :-)
>
> What do you think ?

One way to keep using text files on disk is to use the text mode of
the URL generator to read them. But then of course you would do this
at the XPL level instead of doing this at the XSLT level. More on:

http://www.orbeon.com/ops/doc/processors-generators-url#text-mode

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet