我在外部DTD中使用外部实体引用时遇到一些问题
例如
[name.xml的]
<?xml version="1.0" ?>
<!DOCTYPE simple SYSTEM "simple.dtd">
<simple>
<name> &a; </name>
<age> 21 </age>
<address> bsk street </address>
</simple>
Run Code Online (Sandbox Code Playgroud)
[name.dtd]
<?xml version="1.0" ?>
<!ELEMENT simple (name,age,address)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT a "abhijeet">
Run Code Online (Sandbox Code Playgroud)
当我在Internet Explorer上运行此程序时,我收到错误...
我是一个完全新手xslt.我正在尝试进行一个转换,对源xml文档进行微小的更改,例如:
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns:xliff="urn:oasis:names:tc:xliff:document:1.1" version="1.1">
<file>
<trans-unit>
<source>Kodiak1 [[Name]]</source>
<target></target>
</trans-unit>
</file>
</xliff>
Run Code Online (Sandbox Code Playgroud)
至:
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns:xliff="urn:oasis:names:tc:xliff:document:1.1" version="1.1">
<file>
<trans-unit>
<source>Kodiak1 [[Name]]</source>
<target>Kodiak1 <ph>Name</ph></target>
</trans-unit>
</file>
</xliff>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我想出了:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="target">
<target>
<xsl:value-of select="preceding-sibling::source" />
</target>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
它将文本从<source>节点复制到<target>节点但现在我被卡住了 - 尤其是因为如果我添加另一个<xsl:template match="...">它与原始文本匹配(例如,不在新文本上 - 你能告诉我下一步应该是什么吗?
我已经在 eclipse 中安装了 TestNG 插件,但仍然看到以下错误 引用的文件包含错误(http://testng.org/testng-1.0.dtd)。有关详细信息,请右键单击问题视图中的消息并选择“显示详细信息...”
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="PVAI-Document">
<test name="document-module">
<packages>
<package name="com.genpact.pvai.document.*" />
</packages>
</test>
</suite>
Run Code Online (Sandbox Code Playgroud) 我正在尝试帮助朋友解决计算机课程带回家的测验。我有一个简单的 XML 文件,如下所示,它定义了我在我的书架上拥有的 DVD 标题......
<Inventory>
<DVD>
<Name>Captain America</Name>
</DVD>
<DVD>
<Name>Green Lantern</Name>
</DVD>
<DVD>
<Name>Thor</Name>
</DVD>
</Inventory>
Run Code Online (Sandbox Code Playgroud)
假设“美国队长”和“雷神”都已签出,而“绿灯侠”仍然可用。我想将上述 XML 文件转换为以下 XML ...
<Inventory>
<DVD>
<Name>Captain America</Name>
<Status>Checked-Out</Status>
</DVD>
<DVD>
<Name>Green Lantern</Name>
<Status>Available</Status>
</DVD>
<DVD>
<Name>Thor</Name>
<Status>Checked-Out</Status>
</DVD>
</Inventory>
Run Code Online (Sandbox Code Playgroud)
有人可以分享如何利用 XSL 将 Status 元素添加到每个节点吗?我只有下面的代码片段,但它为所有节点复制了相同的元素。
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="DVD">
<xsl:copy>
<xsl:copy-of select="@*|node()"/>
<Status>Checked-Out</Status>
</xsl:copy>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
非常非常非常非常感谢...
我正在寻找一种更简单,更优雅的方式来替换XML中的文本.对于源XML,例如:
<A>
<B>
<Name>ThisOne</Name>
<Target>abc</Target>
</B>
<B>
<Name>NotThisOne</Name>
<Target>abc</Target>
</B>
<B>
<Name>ThisOne</Name>
<Target>def</Target>
</B>
</A>
Run Code Online (Sandbox Code Playgroud)
我想将名称为"ThisOne"的所有Target元素的文本更改为"xyz".
结果将是:
<A>
<B>
<Name>ThisOne</Name>
<Target>xyz</Target> <-- Changed.
</B>
<B>
<Name>NotThisOne</Name>
<Target>abc</Target>
</B>
<B>
<Name>ThisOne</Name>
<Target>xyz</Target> <-- Changed.
</B>
</A>
Run Code Online (Sandbox Code Playgroud)
我完成了这个:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="B/Target">
<xsl:choose>
<xsl:when test="../Name/text()='ThisOne'"><Target>xyz</Target></xsl:when>
<xsl:otherwise><Target><xsl:value-of select="text()"/></Target></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我在想这可以用<xsl:template match ="B/Target/text()">完成,所以我可以只替换文本而不是整个元素,但我无法弄清楚其余部分.
提前致谢.
我试图从对图形的引用中确定当前章节中包含的图形编号。
要求:
<figure_reference>,可能出现在任何深度。XML:
<top>
<chapter>
<dmodule>
<paragraph>
<figure>figure</figure>
</paragraph>
<figure>figure</figure>
</dmodule>
</chapter>
<chapter>
<dmodule>
<figure>figure</figure>
<paragraph>
<figure>figure</figure>
</paragraph>
</dmodule>
<dmodule>
<figure>figure</figure>
<paragraph>
<figure>figure</figure>
<paragraph>
<figure>figure</figure>
</paragraph>
</paragraph>
<figure_reference id="c"/>
<figure id="c">figure</figure>
</dmodule>
</chapter>
</top>
Run Code Online (Sandbox Code Playgroud)
XSL:
<xsl:template match="figure_reference">
<xsl:value-of select="count(ancestor::dmodule//figure[@id = current()/@id]/preceding::figure)+1"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
当前计数结果:8
期望计数结果:6
我下载了SaxonHE9-4-0-6J并希望在CLI上处理XHTML.然而,Saxon试图从W3C加载DTD,并且每个简单的命令都需要花费太多时间.
我有xml目录,我通过设置env变量指向目录文件成功使用xmllint,但我不知道如何让Saxon使用它.谷歌揭示了使用撒克逊目录的变化(因此混乱)的整个历史,没有一个让我高兴.
我下载了resolver.jar并将其设置在我的CLASSPATH中,但我不能让Saxon使用它.经过各种组合之后,我只使用了目录变量来跟踪http://www.saxonica.com/documentation/sourcedocs/xml-catalogs.xml,例如:
-catalog:path-to-my-catalog
(尝试都URI和常规路径),和不设定-r,-x,-y开关,但撒克逊不会看到它.我收到此错误:
查询处理失败:无法加载Apache目录解析程序库
resolver.jar在我的类路径中设置,我可以从命令行使用它:
C:\temp>java org.apache.xml.resolver.apps.resolver
Usage: resolver [options] keyword
Where:
-c catalogfile Loads a particular catalog file.
-n name Sets the name.
-p publicId Sets the public identifier.
-s systemId Sets the system identifier.
-a Makes the system URI absolute before resolution
-u uri Sets the URI.
-d integer Set the debug level.
keyword Identifies the type of resolution to perform:
doctype, document, entity, notation, public, system,
or …Run Code Online (Sandbox Code Playgroud) 我一直在使用一个简单的CD目录XML文件:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
Run Code Online (Sandbox Code Playgroud)
使用此方法,我想创建一个新CD元素:
private static void addCd(File xml) throws ParserConfigurationException, TransformerConfigurationException, TransformerException, SAXException, IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(xml);
Element cd = document.createElement("CD");
document.appendChild(cd);
for (int i = 1; i <= 3; i++) {
Element title = document.createElement("TITLE");
Element artist = document.createElement("ARTIST");
Element …Run Code Online (Sandbox Code Playgroud) 我们可以像这样在 DTD 中声明一个元素吗:
<!ELEMENT name (EMPTY | (#PCDATA))>
Run Code Online (Sandbox Code Playgroud)
谢谢
我想在主窗口中添加背景图像,而不更改其中按钮的背景图像,并且还需要保持纵横比
我尝试过
self.centralWidget.setStyleSheet("background-image: url(The_Project_logo.png); background-repeat: no-repeat; background-position: center")
但这会改变所有小部件的背景图像