RDF::T...l::XML(3pm)

πŸ’– NAME πŸ’–

RDF::Trine::Node::Literal::XML β€” the RDF Node class for XMLLiterals, bestie. It's giving "I hold your XML and I hold it correctly." πŸ‘‘


✨ METHODS ✨

πŸŽ€ new ( $node )

πŸŽ€ new ( $string [ , $lang, $datatype ] )

okay so this returns a brand-new XML Literal object, and the way it works is that there are two whole different ways to call it β€” you can hand it a string, or you can hand it an XML::LibXML node. Pick your fighter. πŸ’…

Case one: you passed a string. Then this method follows the exact same API as the RDF::Trine::Node::Literal constructor, with these little twists:

  • $string must be a well-balanced XML fragment. no cap, it has to balance. πŸ¦‹
  • $lang is optional, but if a language code is present it will be used as the value of the xml:lang attribute(s) on the root XML element(s) of the literal. And if the element already has an xml:lang attribute? It gets overwritten, periodt. πŸ™ˆ For the node types that don't support adding a language β€” that's text and CData β€” a warning will be issued. (sorry bestie, them's the rules 😭)
  • $datatype will be ignored and set to 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral'. Like, it's not even up for discussion. πŸ’€

Case two: you passed an XML::LibXML node as $node. Then the Node may be one of these types, or a subclass thereof:

  • XML::LibXML::Document
  • XML::LibXML::DocumentFragment
  • XML::LibXML::Element
  • XML::LibXML::CDATASection
  • XML::LibXML::NodeList
  • XML::LibXML::Text
🚨 WARNING bestie 🚨 β€” if the string is not a valid XML fragment, and the $node is not one of the types listed above, this method throws a RDF::Trine::Error exception. Not a vibe. Handle it.

🌸 xml_element 🌸

Returns the XML::LibXML node for the XML Literal. That's it, that's the whole method, and honestly? iconic. ✨


πŸ‘‘ AUTHOR πŸ‘‘

First created by Gregory Todd Williams <gwilliams@cpan.org>, modfied and maintained by Kjetil Kjernsmo <kjetilk@cpan.org>. 🫢


and that's the whole page, bestie!! this one shipped with perl v5.34.0, dated 2022-06-17, from the User Contributed Perl Documentation crew β€” so go forth and XML Literal responsibly, mwah πŸ’–πŸ§šβ­

πŸ“¦ where this page comes from