Closed satoren closed 1 month ago
The changes introduced in this pull request enhance the XML handling capabilities within the Yex
module. New functions for retrieving parent XML elements, fragments, and text have been added to the Yex.Nif
, Yex.Xml
, Yex.XmlElement
, and Yex.XmlText
modules. Corresponding updates to the protocol and type definitions ensure that these new functions integrate seamlessly with existing functionality. Additionally, new test cases have been implemented to verify the correctness of the parent retrieval features.
File | Change Summary |
---|---|
lib/nif.ex | Added functions: xml_fragment_parent/2 , xml_element_parent/2 , xml_text_parent/2 returning NIF error if not loaded. |
lib/shared_type/xml.ex | Added function parent/1 to Yex.Xml protocol, delegating to Yex.XmlText and Yex.XmlElement . |
lib/shared_type/xml_element.ex | Added functions: next_sibling/1 , prev_sibling/1 , parent/1 to Yex.XmlElement . |
lib/shared_type/xml_text.ex | Added type definition for t , and functions: prev_sibling/1 , parent/1 , next_sibling/1 . |
lib/shared_type/xml_fragment.ex | Added function parent/1 to Yex.XmlFragment , and new module Yex.XmlFragmentPrelim with new/1 . |
native/yex/src/xml.rs | Added functions: xml_fragment_parent , xml_element_parent , xml_text_parent for parent retrieval. |
native/yex/src/yinput.rs | Modified NifYInput::XmlFragmentPrelim to map to TypeRef::XmlFragment in into_content method. |
test/shared_type/xml_element_test.exs | Added test case for Yex.Xml.parent/1 in YexXmlElementTest . |
test/shared_type/xml_text_test.exs | Added test case for Yex.Xml.parent/1 in YexXmlTextTest . |
test/shared_type/xml_fragment_test.exs | Added doctest for Yex.XmlFragmentPrelim and test case for XmlFragment.parent/1 in YexXmlFragmentTest . |
sequenceDiagram
participant User
participant Yex.Xml
participant Yex.XmlElement
participant Yex.Nif
User->>Yex.Xml: parent(xml)
Yex.Xml->>Yex.XmlElement: parent(xml)
Yex.XmlElement->>Yex.Nif: xml_element_parent(xml, cur_txn)
Yex.Nif-->>Yex.XmlElement: :erlang.nif_error(:nif_not_loaded)
Yex.XmlElement-->>Yex.Xml: result
Yex.Xml-->>User: result
🐰 In the XML grove, where elements play,
A parent is sought, come what may.
With functions anew, we hop and we cheer,
For fragments and text, their paths are now clear!
Let's dance through the nodes, with joy in our hearts,
As XML's magic in code now imparts! 🌼
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Summary by CodeRabbit
New Features
parent
function to theYex.Xml
protocol for handling XML relationships.Yex.XmlElement
,Yex.XmlText
, andYex.XmlFragment
modules with new functions for sibling and parent retrieval.Tests