我在 Saxon-HE 9.8 中使用 XSLT 3.0,并希望将 JSON 文档作为JSON-LD 中的链接数据使用。在 JSON-LD 中,完整的 HTTP URI 通常显示为值。
当我使用 XPath 3.1fn:serialize将数据返回到 JSON 时,其中的实线字符http://被转义。序列化回 JSON 时是否可以避免这种转义?
该fn:parse-json函数有一个escape可以设置为true()or的参数false(),但我没有看到任何类似的fn:serialize.
我可以使用 删除转义字符fn:replace,但想知道是否有我缺少的内置方法。
示例样式表:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:variable name="j" expand-text="no"> { "@context": "http://schema.org" } </xsl:variable>
<xsl:template name="init">
<xsl:sequence
select="
$j => parse-json(map {'escape': false(), 'liberal': true()})
=> serialize(map {'method': 'json'})
=> replace('\\/', '/') …Run Code Online (Sandbox Code Playgroud) 我有一份包含结构化条目的期刊参考书目的 OCR 文本。我想使用不可见的 XML标准来提取和解析条目。
\n输入示例:
\n\n1 2 Hype. 1990?- 1993. Frequency: Bimonthly. River Edge, \n\nNJ. Published by Word Up! Video, Inc. Last issue 66 pages. \nHeight 28 cm. Line drawings; Photographs (some in color); \nCommercial advertising; Table of contents. Previous editor(s): \nMarica A. Cole. ISSN 1056-4632. LC card no. sn91-1965. \nOCLC no. 23715422. Subject focus and/or Features: Hip hop \nculture, Music, Rap music. \n\nWHi v.l, n.6; v.2, n.5 Pam 01-5450 Aug, 1992; Aug, 1993 …Run Code Online (Sandbox Code Playgroud)