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

Re: Basics of XSLT

Subject: Re: Basics of XSLT
From: James Fuller <james.fuller.2007@xxxxxxxxx>
Date: Tue, 10 Mar 2009 12:27:23 +0100
Re:  Basics of XSLT
http://xmltwig.com/article/index_wtr.html

'ways to rome' series is good ... there is also a bit of perl specific
xml advice to be had at http://www.perlmonks.com

hth, Jim Fuller

On Tue, Mar 10, 2009 at 11:54 AM, Nic Gibson <nicg@xxxxxxxxxx> wrote:
> 2009/3/10 himanshu padmanabhi <himanshu.padmanabhi@xxxxxxxxx>:
>> Thank you.Can anyone explain XPath more?
>>
>> I was advised to use "XML::LibXSLT::xpath_to_string" in the following
code.
>>
>>  my $parser = XML::LibXML->new();
>>  my $xslt = XML::LibXSLT->new();
>>
>>  my $source = $parser->parse_file($xmlfile);
>>  my $style_doc = $parser->parse_file($xslfile);
>>
>>  my $stylesheet = $xslt->parse_stylesheet($style_doc);
>>
>>  my $results = $stylesheet->transform($source,
>> XML::LibXSLT::xpath_to_string(args => "$in{'args'}",value => "$value",
>> cnt => "1",);
>>
>>  print $stylesheet->output_string($results);
>>
>
> Hello again.
>
> One thing you might find useful is the perl-xml mailing list (take a
> look at http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/perl-xml).
>
> I'll try and answer your question about xpath_to_string. In xslt the
> value of a parameter (or variable) is an xpath exrpession in something
> like:
>
> <xsl:param name='myparam' select='foo'/>
>
> That is, we aren't talking about the string 'foo' here, we are talking
> about the element 'foo'. Now, that is like to not be what you mean in
> a global parameter (one at stylesheet level as opposed to a local
> param at template level). A string must be quoted in an xpath
> expression:
>
> <xsl:param name='myparam' select="'foo'"/> <!-- double quote with
> single quoted string inside it -->
>
> So... going back to perl - xpath_to_string converts a perl string to
> the quoting format required by xslt.
>
> The input to the function is a hash (or an array of key/value pairs).
> Basically the function takes every second argument and quotes it. It
> then returns the processed array. So, the result of:
>
> XML::LibXSLT::xpath_to_string(args => "$in{'args'}",value => "$value",
>  cnt => "1",)
>
> will be
>
> ('args' => "'xxx'", 'value' => "'yyy'", 'cnt', => "'1'"); # double
> quoted strings containing single quoted values
>
> where xxx and yyy are the values of $in{'args'} and $value respectively.
>
> I think I gave you an incorrect answer yesterday because I suggested
> xpath_to_string('foo') - don't do that, do as you were doing before
> (xpath_to_string('foo', 'bar')).
>
>
> cheers
>
> nic
>
> --
> Nic Gibson
> Director, Corbas Consulting
> Editorial and Technical Consultancy
> http://www.corbas.co.uk/

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.