[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: using {} brackets with xsl:result-document href (S

Subject: Re: using {} brackets with xsl:result-document href (Saxon 7.4)
From: "malcolm macaulay" <malcolm_xslt_list@xxxxxxxxxxx>
Date: Wed, 23 Apr 2003 05:11:34 +1200
macaulay brackets
Thanks Jeni!

That is now crystal clear. I have been using {} for a while but I totally misunderstood what it was doing.

cheers

Malcolm


From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: "malcolm macaulay" <malcolm_xslt_list@xxxxxxxxxxx>
CC: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: using {} brackets with xsl:result-document href (Saxon 7.4)
Date: Tue, 22 Apr 2003 16:13:37 +0100


Hi Malcolm,

> Can someone please explain why I need to use {} bracket in the href
> of xsl:results-document?

The href attribute can take a literal value. For example:

  <xsl:result-document href="index.html">
    ...
  </xsl:result-document>

tells the processor to associate the result document with the URI
"index.html".

If you want to have the path to the result document you're creating be
dependent on something you compute within the stylesheet then use the
attribute value template:

  <xsl:result-document href="{$vFilePath}">
    ...
  </xsl:result-document>

The XPath expression within the {}s is evaluated and the string value
is inserted into the attribute value. Then the attribute value is used
as normal. So if $vFilePath had the value 'index.html', this would be
exactly the same as using 'index.html' literally as above.

> I'm familiar with using {} as a shortcut for writing values into
> output attributes but I'm not sure why I can't do something like:
>
> <xsl:result-document href="string($vFilePath) ...

This means that the URI associated with the result document is,
literally, "string($vFilePath)". That isn't a legal URI, which is why
Saxon is objecting to it.

> Below are some examples of xsk:result-document which have confused
> me.
[snip]
> This works..
>
> <xsl:template match="file">
> <xsl:variable name="vFileName" select="concat( 'file:///' , @path ,
> $fileSep , 'test.xml' )"/>
> <xsl:result-document href="{$vFileName}" >
> <x>output..</x>
> </xsl:result-document>
> </xsl:template>


Here, the value of the $vFileName is used as the value of the href
attribute. Since the value of $vFileName is a string which is a legal
URI, this is fine.

> This does not work.... Saxon says : The system identifier of the principal
> output file is unknown..
>
> <xsl:template match="file">
> <xsl:variable name="vFileName" select="concat( 'file:///' , @path ,
> $fileSep , 'test.xml' )"/>
> <xsl:result-document href="$vFileName" >
> <x>output..</x>
> </xsl:result-document>
> </xsl:template>


Here, the literal string "$vFileName" is used as the URI. That isn't a
valid URI, so Saxon objects to it.

> This works..
>
> <xsl:template match="file">
>
> <xsl:result-document href="{'file:///'}{@path}{$fileSep}{'test.xml'}" >
> <x>output..</x>
> </xsl:result-document>
> </xsl:template>


Each XPath expression is evaluated and inserted in place. The result
is a legal URI, so Saxon does not object. It would be exactly the same
if you used:

  <xsl:result-document href="file:///{@path}{$fileSep}test.xml">
    ...
  </xsl:result-document>

There's no need to use {}s for literal strings.

> This does not work.... Saxon says : The system identifier of the principal
> output file is unknown..
>
> <xsl:template match="file">
> <xsl:variable name="vFileName" select="concat( 'file:///' , @path ,
> $fileSep , 'test.xml' )"/>
> <xsl:result-document href="string($vFileName)" >
> <x>output..</x>
> </xsl:result-document>
> </xsl:template>


Again, the literal string "string($vFileName)" is not a URI, so Saxon
objects to it.

>         This works...
>         -->
>         <xsl:template match="file">
>                 <xsl:result-document href="file:///{@path}\test.xml"  >
>                         <x>output..</x>
>                 </xsl:result-document>
>         </xsl:template>

Right. A string made up of 'file:///', the value of the path
attribute, and '\test.xml' is a legal URI.

> This does not work.... Saxon says : The system identifier of the principal
> output file is unknown..
>
> <xsl:template match="file">
> <xsl:result-document href="concat( 'file:///' , @path , $fileSep ,
'test.xml' )">>
> <x>output..</x>
> </xsl:result-document>
> </xsl:template>


Again, the literal string "concat(...)" is not a legal URI so Saxon
objects to it.

Basically, if you put it in {}s it gets evaluated. If you don't, it
gets treated as a literal string.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.