xml 相关问题

可扩展标记语言(XML)是一种灵活的结构化文档格式,用于定义人类和机器可读的编码规则。

正确的 xs:ID 允许的 ID 名称是什么?

我正在尝试为其中一个标签的 id 属性定义一个 ID。文档和 xsd 架构要求使用 xs:id 确认 id 集。 我尝试了“ID_123”,但当我尝试时......

回答 1 投票 0

XSD:将主列表中相同元素的列表映射并重命名到不同的字段

我有一个导出的 xml 类似于以下内容: 由于存在多个地理元素,到目前为止,我拥有的 xsd 为 1 个站点创建了多行: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="divesites" type="divesitesType"/> <xs:complexType name="geoType"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute type="xs:byte" name="cat" use="optional"/> <xs:attribute type="xs:byte" name="origin" use="optional"/> <xs:attribute type="xs:string" name="value" use="optional"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:complexType name="siteType"> <xs:sequence> <xs:element type="xs:string" name="notes" minOccurs="0"/> <xs:element type="geoType" name="geo" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> <xs:attribute type="xs:string" name="uuid" use="optional"/> <xs:attribute type="xs:string" name="name" use="optional"/> <xs:attribute type="xs:string" name="gps" use="optional"/> <xs:attribute type="xs:string" name="description" use="optional"/> </xs:complexType> <xs:complexType name="divesitesType"> <xs:sequence> <xs:element type="siteType" name="site" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema> 我认为要走的路是限制和模式,但我对 xsd + excel 不够熟悉,无法使其正常工作。 所以请帮忙。 并不是说 Excel 对于 xsd 映射有一些限制: There are several types of XML schema element constructs Excel doesn't support. The following XML schema element constructs can't be imported into Excel: <any> This element allows you to include elements that aren't declared by the schema. <anyAttribute> This element allows you to include attributes that aren't declared by the schema. Recursive structures A common example of a recursive structure is a hierarchy of employees and managers in which the same XML elements are nested several levels. Excel doesn't support recursive structures more than one level deep. Abstract elements These elements are meant to be declared in the schema, but never used as elements. Abstract elements depend on other elements being substituted for the abstract element. Substitution groups These groups allow an element to be swapped wherever another element is referenced. An element indicates it's a member of another element's substitution group through the <substitutionGroup> attribute. Mixed content This content is declared by using mixed="true" on a complex type definition. Excel doesn't support the simple content of the complex type but does support the child tags and attributes defined in that complex type. 因为无论如何我都需要事先进行转换步骤,所以我使用了一个也可以输出 csv 的 python 转换脚本。 有兴趣的朋友: https://github.com/hwillemen/subsurface-divelogs-scripts/blob/main/Divesites_sorter.py

回答 1 投票 0

java.lang.Long 无法转换为 java.util.Map 但我不会转换任何 long

私有静态Serializer序列化器; 私有静态 Map 用户 = new HashMap<>(); // 私有静态 Map admins = new HashMap<>(); 私人静态地图...

回答 1 投票 0

Saxon-JS JSON 到 XML 转换仅返回 SEF 文件中的数据

我正在尝试创建一个 Javascript 工具,可以使用 Saxon-JS 将 AuthzForce 的 XACML 策略转换为 JSON 并返回。本文档提供了所需的 XSL 样式表。从 XML 转换为

回答 1 投票 0

反序列化 XML 不适用于某个字段

我正在尝试将 XML 流反序列化为对象。它适用于除一个领域之外的所有领域,而且我无法弄清楚该领域出了什么问题。为了确保我知道我在处理什么,我...

回答 2 投票 0

根据通道编号顺序,应选择值

我需要根据输入 xml 中的通道编号顺序选择值 1 生活 <

回答 1 投票 0

定义具有唯一属性的可重用类型

我想创建一个模式,需要在给定元素内: 给定的子元素必须至少出现一次 如果给定的子元素出现多次,则每次出现...

回答 1 投票 0

在 NestedScrollView 中滚动 WebView 内容很困难

问题 我在包含 NestedScrollView 和 ConstraintLayout 的 Android XML 布局中遇到滚动问题。尽管将 NestedScrollView 配置为允许在

回答 1 投票 0

findViewById(R.id.activity_main) --> 无法解析符号“activity_main”

!!请注意 !!调用setContentView()方法时不会出现该错误。在寻找答案时,我发现有人在这里发布了完全相同的问题(来自

回答 5 投票 0

房地产 XML 标准

房产列表有标准的 XML 格式吗? 我找到了几个: reaxml1 reaxml.realestate.com.au/docs/reaxml1-xml-format.html RELML www.xml.com/98/08/real/relml-dtd.html 但这是...

回答 4 投票 0

需要从不同费率中获取金额

我需要使用相同的带值从多个费率中获取特定金额 输入 xml 我有: 2000

回答 1 投票 0

构建 XML feed 后对项目进行排序?

我在基于 XML 的 CMS(现代校园)工作。 XSLT 仍然是我试图即时学习的东西,所以我还不太熟悉这个领域。 我们的 CMS 正在构建一个博客提要(其中...

回答 1 投票 0

将 XML 表转换为 R 中的 tibble

我正在尝试将具有不同行数和列数的 XML 表转换为数据帧。我可以使用格式良好、可预测的表格来做到这一点,如下两个表格: ... 我正在尝试将具有不同行数和列数的 XML 表转换为数据帧。我可以使用格式良好、可预测的表格来做到这一点,就像这两个表格一样: <table xml:id="a"> <row role="label"> <cell cols="2">Stuff</cell> </row> <row> <cell>Thing</cell> <cell>1</cell> </row> <row> <cell>Another thing</cell> <cell>2</cell> </row> </table> <table xml:id="b"> <row role="label"> <cell cols="2">Nonsense</cell> </row> <row> <cell>Thing</cell> <cell>3</cell> </row> <row> <cell>Anything</cell> <cell>2</cell> </row> <row> <cell>Another thing</cell> <cell>2</cell> </row> </table> 我可以将它们更改为这样的小标题: # A tibble: 5 × 4 id label cell.1 cell.2 <chr> <chr> <chr> <dbl> 1 a Stuff Thing 1 2 a Stuff Another thing 2 3 b Nonsense Thing 3 4 b Nonsense Anything 2 5 b Nonsense Another thing 2 使用此代码: x <- "table.xml" file <- read_xml(x) cells <- file %>% xml_find_all(".//cell") output <- lapply(cells, function(d){ id <- d %>% xml_find_first(".//parent::row/parent::table")%>% xml_attr("id") label <- d %>% xml_find_first(".//parent::row/preceding-sibling::row[@role='label']")%>% xml_text() cell.1 <- d %>% xml_find_first(".//parent::row/cell")%>% xml_text() cell.2 <- d %>% xml_find_all(".//following-sibling::cell")%>% xml_double() tibble(id, label, cell.1, cell.2) }) answer <- do.call(rbind, output) 但是,这种方法依赖于提供的属性 (@role='label')、一致的单元格数量等。我需要在一堆格式不规则的 XML 表上运行此脚本。 如果我向上例中的某一行添加一个额外的单元格,我的方法就会失败。我怀疑我可能以错误的方式处理这个问题。例如,我可以用 xml2::as_list() 来做到这一点吗?我的尝试还没有成功。 这是一种使用 rvest 包和 tidyverse 转换中的 html_table 的可能方法。注意:您显示的 XML 无效。 ### Packages library(xml2) library(rvest) library(stringr) library(dplyr) library(purrr) ### Parse the XML and transform the result as character a=read_xml("C:/Users/YourName/Downloads/YourFile.xml") b=as.character(a) ### Replace the content of the XML to conform the tables to HTML tables structure b=str_replace_all(b,"cell cols","td colspan") b=str_replace_all(b,"row","tr") b=str_replace_all(b,"cell","td") ### Parse the result of the transformation c=read_xml(b) ### Get all ids of the tables attr=html_elements(c,xpath = "//table") %>% html_attrs() %>% unlist() ### Get all the tables temp=c%>% html_elements(xpath = "//table") %>% html_table() ### Declare a function to transform the tables ### Transform the last column from character to numeric transform=function(x,y){x %>% slice(-1) %>% mutate(id=y, label=x[1,1][[1]],.before=1, X2=as.numeric(X2))} ### Apply the function done=map2(.x = temp,.y = attr,.f = transform) ### Stack the tables and rename the columns end=bind_rows(gigachad) %>% rename_with(.fn = ~str_replace(.x,"X","cell."), .cols = starts_with("X")) 输出: # A tibble: 5 × 4 id label cell.1 cell.2 <chr> <chr> <chr> <dbl> 1 a Stuff Thing 1 2 a Stuff Another thing 2 3 b Nonsense Thing 3 4 b Nonsense Anything 2 5 b Nonsense Another thing 2

回答 1 投票 0

如何读取 XML 文件并解析它

我想知道如何使用ABAP读取xml文件,我在网上搜索过但没有找到足够清晰的答案。有人可以帮助我吗? 提前致谢, 沙米龙

回答 4 投票 0

为什么last()选择以下XML中的两个标签?

给出以下 XML: 嗨!这是 xpather 测试版... 这个网络应用程序使您能够查询 XML/HTML 文档...

回答 1 投票 0

SCCM 中缺少 XML 根元素

我遇到了一个问题,由于 XML 损坏,导致 SCCM 配置管理器控制台停止显示应用程序信息。 在互联网上查了一下,发现了以下内容......

回答 1 投票 0

如何使用 Ansible playbook 从 SOAP API 响应中获取标签值?

问题陈述 我们正在使用 Ansible 在 Windows 主机上运行 SOAP API 并尝试从 API 响应中获取值,但是,由于无效的 XPath 异常,我们无法获取值。 主要

回答 1 投票 0

使用ansible playbook运行时无法从soap api响应中获取标签值

问题陈述:我们正在使用ansible在Windows主机上运行soap-api并尝试从api响应中获取值,但是,由于无效的xpath异常,我们无法获取值。 ...

回答 1 投票 0

如何使用 XDocument 保留多行 XML 格式的属性?

我正在使用 XML 来编辑属性和值。我有一个这种格式的 XML 节点。 我正在使用 XML 来编辑属性和值。我有一个这种格式的 XML 节点。 <add attribute1="value" attribute2="ghjg" attribute3="ghjg" attribute4="ghjg" /> 更改保存值后,它会更改为 <add attribute1="value" attribute2="ghjg" attribute3="ghjg" attribute4="ghjg" /> 我尝试了 LoadOptions 和 SaveOptions,但没有一个起作用。 XDocument xmlFile = XDocument.Load(xmlCondigurationPath,LoadOptions.PreserveWhitespace); xmlFile.Save(xmlCondigurationPath,SaveOptions.DisableFormatting); 将 XmlWriter 与 XmlWriterSettings 一起使用。 var settings = new XmlWriterSettings { NewLineOnAttributes = true, Indent = true }; using var writer = XmlWriter.Create("test.xml", settings); xDocument.Save(writer);

回答 1 投票 0

XSLT 在输出到 DOM 时将 <image> 节点转换为 <img> 标签

现在是 2024 年,我正在做一个融合 XSLT 技术的项目。 我想出了一种简单的方法来访问 XML 文件,该文件正在使用 javascript 进行简单转换,但将其输出到 hi...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.