Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

URI resolution

by abhishes (Friar)
on Jun 20, 2002 at 12:06 UTC ( [id://175970]=perlquestion: print w/replies, xml ) Need Help??

abhishes has asked for the wisdom of the Perl Monks concerning the following question:

Hello All, I have an XSL file in which I have some custom URI like <xsl:include href="myuri:basexsl.xsl" /> When I use apache Xerces api I can implement in the URIResolver interface and implement the logic which will do the uril resolution for me. How do I do the same thing in perl? currently my rendering of the stylesheet is failing as the uri resolution is not happening. regards, Abhishek.

Replies are listed 'Best First'.
Re: URI resolution
by Matts (Deacon) on Jun 20, 2002 at 12:17 UTC
    With XML::LibXSLT, you implement the LibXML callbacks:
    # in your parsing routine: my $parser = XML::LibXML->new(); local $XML::LibXML::match_cb = \&match_uri; local $XML::LibXML::open_cb = \&open_uri; local $XML::LibXML::read_cb = \&read_uri; local $XML::LibXML::close_cb = \&close_uri; my $doc = $parser->parse_file($file); $doc->process_xinclude(); my $style_doc = $parser->parse_file($stylesheet); my $stylesheet = XML::LibXSLT->parse_stylesheet($style_doc); my $results = $stylesheet->transform($doc); ... # the sub definitions: # NB: This is just one example using a string - the # return from open_uri is an opaque type, so you can # use a file handle if that's appropriate sub match_uri { my $uri = shift; # warn("match: $uri\n"); return $uri !~ /^\w+:/; # only handle URI's without a scheme } sub open_uri { my $uri = shift; # warn("open: $uri\n"); my $str = some_function_to_get_the_uri($uri); return $str; } sub close_uri { } sub read_uri { return substr($_[0], 0, $_[1], ""); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://175970]
Approved by RMGir
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2025-07-15 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.