AI Decision System
Replayable, offline-verifiable records for AI-assisted go/no-go decisions: experiment promotions, typed model answers and human-approved actions.
Expat 파서를 내장해 XML을 읽고 탐색·작성하며 시스템 XML 라이브러리 없이 동작
Reads, navigates, and writes XML documents using a bundled copy of the Expat parser (<https://libexpat.github.io/>), so that no system XML library is required. Documents are parsed into a faithful imm
개발 도구R · CGitHub @pedrobtz온라인운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
아직 감지된 업데이트가 없습니다. GitHub 릴리스가 나오면 여기에 보입니다.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기Small and Secure XML Parser and Document Tree
저장소 README에서 가져옴
README 전체를 불러오는 중입니다. 아래는 저장된 발췌입니다.
zuxml reads, navigates and writes XML in R, using a bundled copy of the
Expat parser, so no system XML library is
required. Documents are parsed into an immutable tree exposed through a small
vectorized navigation API. It is built for untrusted input: document type
declarations are rejected, external entity resolution is not compiled in at all,
and configurable limits bound nesting depth and memory use.
xml_parse() takes a string or a raw vector and returns a document; xml_read()
takes a file path, a URL or a connection, and streams it.README 전문 보기 ↗zuxml reads, navigates and writes XML in R, using a bundled copy of the Expat parser, so no system XML library is required. Documents are parsed into an immutable tree exposed through a small vectorized navigation API. It is built for untrusted input: document type declarations are rejected, external entity resolution is not compiled in at all, and configurable limits bound nesting depth and memory use.
install.packages("zuxml")
Or the development version from GitHub:
# install.packages("pak")
pak::pak("pedrobtz/zuxml")
xml_parse() takes a string or a raw vector and returns a document; xml_read()
takes a file path, a URL or a connection, and streams it.
library(zuxml)
doc <- xml_parse("<catalog>
<book id='b1'><title>The Annotated XML</title><price>29.99</price></book>
<book id='b2'><title>Parsing for Fun</title><price>17.50</price></book>
</catalog>")
xml_find() searches descendants in document order and returns a nodeset
(xml_elements() looks only at direct element children):
xml_find(doc, "title")
#> <zuxml_nodeset[2]>
#> [1] <title> [2] <title>
Every accessor is vectorized over a nodeset, so n nodes give a result of length n and there is usually no loop to write:
books <- xml_elements(xml_root(doc), "book")
xml_attr(books, "id")
#> [1] "b1" "b2"
xml_text(xml_find(doc, "title"))
#> [1] "The Annotated XML" "Parsing for Fun"
as.numeric(xml_text(xml_find(doc, "price")))
#> [1] 29.99 17.50
Tables and lists come out as data frames and nested lists:
page <- xml_parse("<body>
<table>
<tr><th>fruit</th><th>price</th></tr>
<tr><td>apple</td><td>1.20</td></tr>
<tr><td>pear</td><td>0.90</td></tr>
</table>
<ul><li>fruit<ul><li>apple</li><li>pear</li></ul></li><li>bread</li></ul>
</body>")
xml_table(xml_find(page, "table"))[[1]]
#> fruit price
#> 1 apple 1.20
#> 2 pear 0.90
# xml_elements(), not xml_find(): the nested <ul> is a descendant too.
str(xml_list(xml_elements(xml_root(page), "ul"))[[1]])
#> List of 2
#> $ :List of 2
#> ..$ text : chr "fruit"
#> ..$ items:List of 2
#> .. ..$ : chr "apple"
#> .. ..$ : chr "pear"
#> $ : chr "bread"
`xml_read()` reads from a file, a URL or any connection, and feeds the bytes to
the parser as they arrive rather than reading the whole document first:
``` r
feed <- xml_read("https://www.r-project.org/feed.xml") # a URL string
feed <- xml_read(gzfile("archive/feed.xml.gz")) # any connection
feed <- xml_read("feed.xml") # a path
xml_text(xml_find(feed, "title"))
Note that this is XML, not HTML: Expat is strict and non-recovering, so <br> and
friends are an error, not something to recover from. The getting started
article covers namespaces,
serialization, the resource limits and the C interface for package authors.
There are two ways for another package to reach the parser, and they suit different consumers.
The registered function table is the one to prefer. Declare
Imports: zuxml
LinkingTo: zuxml
in DESCRIPTION, and importFrom(zuxml, zuxml_info) in NAMESPACE. The
import is required: Imports: alone does not load zuxml, and the table is
registered only when it loads. Then include <zuxml.h>, which resolves
zuxml_api_get() through R_GetCCallable(). Nothing links against Expat,
and no Expat type appears in the consumer's code. A zuxml update that keeps
the table's version reaches the consumer without a rebuild. One that changes
it, which renames the registered table (zuxml_api_v2 to zuxml_api_v3),
makes the lookup fail with an R error until the consumer is rebuilt. That is
deliberate: it is how a changed struct layout is kept from being read with
the old one. The
getting started article
documents the table and the string-lifetime rules that go with it.
The static archive is for the case the table cannot serve: an existing C library written against Expat's own API, which would have to be rewritten to use anything else. An installed zuxml carries
zuxml/include/expat.h
zuxml/include/expat_external.h
zuxml/lib${R_ARCH}/libzuxml.a
where the archive holds the Expat implementation and no R code. R_ARCH is
empty on most platforms, so the archive is usually in zuxml/lib. LinkingTo: zuxml puts the headers on the include path. A configure script finds the
archive, asking for lib/<arch> first and falling back to lib, and writes
its path into src/Makevars without adding an Imports: dependency:
ZUXML_LIB=$("${R_HOME}/bin/Rscript" --vanilla -e "arch <- .Platform\$r_arch; d <- if (nzchar(arch)) system.file('lib', arch, package = 'zuxml') else ''; if (!nzchar(d)) d <- system.file('lib', package = 'zuxml'); cat(d)")
sed "s|@ZUXML_LIB@|${ZUXML_LIB}|" src/Makevars.in > src/Makevars
PKG_CPPFLAGS = -DXML_STATIC
PKG_LIBS = '@ZUXML_LIB@/libzuxml.a'
The path is quoted because it comes from system.file(), and on Windows the
user library often has a space in its path.
Four things to know before taking this route:
XML_GE is 0 and
XML_DTD is undefined, so general entities, parameter entities and the
external-entity machinery are compiled out rather than switched off. Do not
define XML_GE=1 on your own command line: you would get declarations for
limiter functions the archive does not contain.&e;. Install a DOCTYPE handler and
limits yourself, as vignette("linking") shows.-DXML_STATIC is recommended, not required. Stock expat_external.h
adds __declspec(dllimport) only under Microsoft's compiler, which Rtools
is not. The define is still accurate, and costs nothing.zuxml.so, and a zuxml update, security fixes
included, does not reach your users until you rebuild and re-release.