我有一个包含步骤的程序.一些步骤伴随着图像.
<p class="imagefloatright"><img src="step 1.png"/></p>
<ol>
<li>
<p>Step 1</p>
<p class="imagefloatright"><img src="step 2.png"/></p>
</li>
<li>
<p>Step 2</p>
<p>Step 3</p>
</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
和我的CSS:
p.imagefloatright img {
float: right;
clear: both;
}
Run Code Online (Sandbox Code Playgroud)
这是默认输出.图像不会与它们所属的步骤保持一致,步骤2的文本放在图像1旁边:
我希望属于第2步的图像与第2步垂直对齐:
过去,我通过在每个浮动图像之前插入一个高度为0的全宽度块,在XSL-FO中实现了我想要的结果.
我可以使用CSS命令实现我想要的布局吗?或者,在将CSS应用于HTML之前,是否需要在HTML中插入块?
我有一个具有这种结构的XML文件:
<entry id="1">
<para>first paragraph</para>
<para>second paragraph</para>
</entry>
<entry id="2">
<para></para>
</entry>
Run Code Online (Sandbox Code Playgroud)
如果我的XSL发现一个条目的第一个元素的文本节点是空的(例子中的条目id ="2"),我需要做一些事情.我试过这个:
<xsl:when test="(entry/para[1]/text()='')">
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.
用于读取元素属性的类似代码片段可以正常工作:
<xsl:when test="entry[1]/para[@stylename = 'Table Heading']">
Run Code Online (Sandbox Code Playgroud)
所以我对text()=''选择做错了.搜索建议我应该使用[not(text())]但我无法弄清楚如何在我的代码中集成它.
我有一个 XML 文件,其中包含以文件名开头的部分:
<madcapfile filename="C:\1\Outputpath\The 7% solution.xlf">
Run Code Online (Sandbox Code Playgroud)
每个部分都必须保存到一个单独的文件中。这是我的 XSLT:
<xsl:template match="madcapfile">
<xsl:variable name="file1" select="concat('file:///',@filename)"/>
<xsl:variable name="file2" select="encode-for-uri($file1)"/>
<xsl:variable name="file3" select="concat('file:///',replace(@filename,'%','%25'))"/>
<xsl:result-document method="xml" href="{$file2}">
<xsl:apply-templates select="node()"/>
</xsl:result-document>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
变量 file1、file2、file3 是我迄今为止的尝试。变量 file1 在正确位置为所有文件创建文件,文件名中带有 % 的文件除外。
变量 file3 在所有文件的正确位置创建文件,因此这是一个有效的解决方案。
使用变量 file2 会出现错误:XSLT 处理器 (Saxon 9.7) 尝试将文件写入
C:\Path-to-XSLT\C:\1\Outputpath\The 7% solution.xlf
Run Code Online (Sandbox Code Playgroud)
即它看起来像 encode-for-uri 将其输入视为相对路径,即使它以“C:\”开头
我也尝试将“file:///”添加到路径的开头,这不会改变encode-for-uri 的行为。
有没有办法强制 encode-for-uri 将其输入视为绝对路径?
我想使用 ::before 伪元素插入在 HTML 文件的另一个区域中找到的一些文本。
我的HTML:
<html>
<body notetext="Note">
...
<p class="bodytext">Don't press the red button!</p>
</body>
Run Code Online (Sandbox Code Playgroud)
我可以使用 content:attr 来选择当前元素的属性,但是是否可以引用祖先元素的属性?就像在 XPath 中一样,例如 (//body/@notetext)
我有的不起作用的CSS:
p.bodytext::before {
content:attr(notetext);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Antennahouse Formatter,用于 CSS 分页媒体。