Node

NAME LibXML::Class::Node - base role of types, that can be XML-named and aware of namespacing

DESCRIPTION

This role consumes LibXML::Class::NS.

Attributes

  • Str:D $.xml-name

    A lazy attribute, initialized from a return value of xml-build-name method. While the method is not explicitly required by the role (there are some compile-time issues arrise if it does), but it has to be implemented by a consuming class.

Methods

  • method xml-has-name()

    A predicate, reporting if $.xml-name has been initialized already.

  • method xml-apply-ns(LibXML::Element:D $dest-elem, Bool:D :$default = True, Str :namespace(:xml-default-ns(:$ns)), Str :xml-default-ns-pfx(:$prefix), :$config = $*LIBXML-CLASS-CONFIG)

    Assuming that current object is being serialized into $dest-elem this method applies namespace information to the element, based on what is set for the object itself. This means:

    • adding all prefix definitions from $.xml-namespaces to the element

    • finding out namespace default value and prefix

    • resolving the previous values and setting them on the element

    Namespace default and prefix passed in as $ns and $prefix arguments would override what is set for the object itself even when just one is set. This is a common rule when defining either of two is considered as if both are set, even if the other one is undefined.

    If no namespace is explicitly passed in the arguments and $default is True the corresponding object attributes are taken.

    If the default namespace by now is set and is not empty then it's used as is. An empty one is resolved from $dest-elem by looking up the empty prefix "" ā€“ this is how the default namespace is propagaded from parent XML elements.

    If the prefix is set we also try to resolve it first on the $dest-elem. Don't forget that by now we've already applied all locally defined namespace prefixes to the element making the overall picture complete. If the prefix cannot be resolved then either $config.alert is used to report the problem, or LibXML::Class::X::NS::Prefix is thrown unconditionally. Resolved prefix gets added to the element too.

SEE ALSO

COPYRIGHT

(c) 2023, Vadim Belman [email protected]

LICENSE

Artistic License 2.0

See the LICENSE file in this distribution.

LibXML::Class v0.0.1

General purpose XML de-/serialization for Raku

Authors

  • Vadim Belman

License

Artistic-2.0

Dependencies

LibXML:ver<0.10.0>:auth<zef:dwarring>AttrX::Mooish:auth<zef:vrurg>:api<1.0.0+>:ver<1.0.3+>Hash::Merge:ver<2.0.0>:auth<github:scriptkitties>:api<2>

Provides

  • LibXML::Class
  • LibXML::Class::Attr
  • LibXML::Class::Attr::Node
  • LibXML::Class::Attr::XMLish
  • LibXML::Class::CX
  • LibXML::Class::Config
  • LibXML::Class::Descriptor
  • LibXML::Class::Document
  • LibXML::Class::HOW::AttrContainer
  • LibXML::Class::HOW::Configurable
  • LibXML::Class::HOW::Element
  • LibXML::Class::HOW::ElementRole
  • LibXML::Class::HOW::ElementSeq
  • LibXML::Class::HOW::Explicit
  • LibXML::Class::HOW::Imply
  • LibXML::Class::HOW::Named
  • LibXML::Class::ItemDescriptor
  • LibXML::Class::NS
  • LibXML::Class::Node
  • LibXML::Class::Types
  • LibXML::Class::Utils
  • LibXML::Class::X
  • LibXML::Class::XML

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.