Skip to content

Add support for basic information of XmlDocument struct - #170

Merged
jameslan merged 3 commits into
jameslan:masterfrom
zurborg:feature/xmldocinfo
Sep 5, 2026
Merged

jameslan merged 3 commits into
jameslan:masterfrom
zurborg:feature/xmldocinfo

Conversation

@zurborg

@zurborg zurborg commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #169

@zurborg zurborg changed the title Add support for basic information of XmlDocument struct (#169) Add support for basic information of XmlDocument struct Aug 7, 2026
Comment thread src/document.mts Outdated
Comment on lines +346 to +362
getStandalone(): number | undefined {
return this._ptr === 0 ? undefined : XmlDocStruct.standalone(this._ptr);
}

/**
* Get version string from XML declaration
*/
getVersion(): string | undefined {
return this._ptr === 0 ? undefined : XmlDocStruct.version(this._ptr);
}

/**
* Get actual encoding if any
*/
getEncoding(): string | null | undefined {
return this._ptr === 0 ? undefined : XmlDocStruct.encoding(this._ptr);
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library prefers property getters/setters over get/set methods. Please convert these new methods. You can refer to the XmlDocument.root property getter. Thanks!

Comment thread src/document.mts Outdated
* -2 if there is an XML declaration, but no standalone attribute was specified
*/
getStandalone(): number | undefined {
return this._ptr === 0 ? undefined : XmlDocStruct.standalone(this._ptr);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to have a null check for _ptr. The object is created with a non-null ptr, and it is set to zero only after disposed.

- Convert getVersion()/getEncoding()/getStandalone() to version/encoding/
  standalone property getters, matching XmlDocument.root style
- Drop the _ptr null checks; the pointer is only zero after dispose
- Update tests to the real values of a freshly created document and keep
  the doc alive for the duration of each test
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Coverage after merging feature/xmldocinfo into master will be

100.00%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   c14n.mts100%100%100%100%
   diag.mts99.51%100%90.91%100%
   disposable.mts100%100%100%100%
   disposeShim.mts100%100%100%100%
   document.mts100%100%100%100%
   dtd.mts100%100%100%100%
   index.mts100%100%100%100%
   libxml2.mts99.90%99.20%100%100%684
   metadataShim.mts100%100%100%100%
   nodejs.mts100%100%100%100%
   nodes.mts99.92%99.22%100%100%76
   utils.mts100%100%100%100%
   validates.mts100%100%100%100%
   xpath.mts100%100%100%100%

@jameslan
jameslan merged commit 8cbc032 into jameslan:master Sep 5, 2026
14 checks passed
github-actions Bot pushed a commit that referenced this pull request Sep 5, 2026
jameslan added a commit that referenced this pull request Sep 5, 2026
* Add support for basic information of XmlDocument struct (#169)

---------

Co-authored-by: James Lan <jameslan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for basic information of XmlDocument struct

2 participants