-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP on libxml v2.13.00+ local error handling
- Loading branch information
Showing
15 changed files
with
249 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[[Raku LibXML Project]](https://libxml-raku.github.io) | ||
/ [[LibXML Module]](https://libxml-raku.github.io/LibXML-raku) | ||
/ [XInclude](https://libxml-raku.github.io/LibXML-raku/XInclude) | ||
:: [Context](https://libxml-raku.github.io/LibXML-raku/XInclude/Context) | ||
|
||
class LibXML::XInclude::Context | ||
------------------------------- | ||
|
||
XInclude Processing Context | ||
|
||
Synopsis | ||
-------- | ||
|
||
use LibXML::XInclude::Context; | ||
my LibXML::XInclude::Context $xic .= new(); | ||
$xic.process-xincludes($doc); | ||
|
||
Description | ||
----------- | ||
|
||
XInclude processing context. | ||
|
||
Methods | ||
------- | ||
|
||
Copyright | ||
--------- | ||
|
||
2001-2007, AxKit.com Ltd. | ||
|
||
2002-2006, Christian Glahn. | ||
|
||
2006-2009, Petr Pajas. | ||
|
||
License | ||
------- | ||
|
||
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 [http://www.perlfoundation.org/artistic_license_2_0](http://www.perlfoundation.org/artistic_license_2_0). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#| XInclude Processing Context | ||
unit class LibXML::XInclude::Context; | ||
|
||
use LibXML::_Configurable; | ||
also does LibXML::_Configurable; | ||
|
||
use LibXML::ErrorHandling; | ||
also does LibXML::ErrorHandling; | ||
|
||
use LibXML::_Options; | ||
use LibXML::Parser::Context; | ||
constant %Opts = %( | ||
%LibXML::Parser::Context::Opts, %(:config); | ||
); | ||
also does LibXML::_Options[%Opts]; | ||
|
||
use NativeCall; | ||
|
||
=begin pod | ||
=head2 Synopsis | ||
use LibXML::XInclude::Context; | ||
my LibXML::XInclude::Context $xic .= new(); | ||
$xic.process-xincludes($doc); | ||
=head2 Description | ||
XInclude processing context. | ||
=end pod | ||
|
||
use LibXML::Config; | ||
use LibXML::Document; | ||
use LibXML::Raw; | ||
|
||
has LibXML::Document:D $.doc is required; | ||
has xmlXIncludeCtxt:D $.raw .= new: :doc($!doc.raw); | ||
has uint32 $.flags = self.config.parser-flags; | ||
|
||
# for the LibXML::ErrorHandling role | ||
has Bool ($.recover, $.suppress-errors, $.suppress-warnings) is rw; | ||
|
||
=head2 Methods | ||
|
||
submethod TWEAK(:raw($), *%opts) is hidden-from-backtrace { | ||
|
||
fail "This version of libxml ({self.config.version}) is too old to use XInclude contexts" | ||
unless self.config.version >= v2.13.00; | ||
|
||
$!raw.SetFlags($!flags); | ||
self.init-local-error-handling; | ||
} | ||
|
||
submethod DESTROY { | ||
.Free with $!raw; | ||
} | ||
|
||
multi method process-xincludes(::?CLASS:U: LibXML::Document:D :$doc!, *%opts --> Int) is hidden-from-backtrace { | ||
self.new(:$doc, |%opts).process-xincludes; | ||
} | ||
|
||
multi method process-xincludes(::?CLASS:D: LibXML::Element:D :$elem = $!doc.root --> Int) is hidden-from-backtrace { | ||
self.do: :$!raw, { | ||
$!raw.ProcessNode($elem.raw); | ||
} | ||
} | ||
|
||
=begin pod | ||
=head2 Copyright | ||
2001-2007, AxKit.com Ltd. | ||
2002-2006, Christian Glahn. | ||
2006-2009, Petr Pajas. | ||
=head2 License | ||
This program is free software; you can redistribute it and/or modify it under | ||
the terms of the Artistic License 2.0 L<http://www.perlfoundation.org/artistic_license_2_0>. | ||
=end pod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.