xslt apply-templates忽略一个子类型(xslt apply-templates ignore one child type)
我在XSLT中使用了以下XML。
<section level="sect4" number-type="manual" num="(ii)"> <title> Non-Hong Kong companies <footnote num="123"> <para>The venerable statutory .</para> </footnote> with a place of business in Hong Kong <footnote num="124"> <para>It may be noted in this context of English judgments.</para> </footnote> </title> <para> <phrase>3.039</phrase> Companies incorporal Companies, <footnote num="125"> <para>Registration of the information specified in this section must be effected</para> </footnote> of which three are relevant for present purposes: </para> </section>
这里我想申请模板,但忽略脚注,当我使用下面。
<xsl:template name="IndexItem"> <xsl:if test="not(contains(@level,'sect1'))"><!--changed fron @num to sect2--> <xsl:variable name="tocpg"> <xsl:value-of select="concat('#P',descendant::phrase[1])"/> </xsl:variable> <xsl:variable name="nu"> <xsl:number format="(i)"/> </xsl:variable> <xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/> <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/> <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="text" select="current()/title/text()"/> <xsl:variable name="Brac"> <xsl:choose> <xsl:when test="contains(current()/@num,$nu)"> <xsl:value-of select="3"/> </xsl:when> <xsl:when test="contains(current()/@num,'(')"> <xsl:value-of select="2"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="1"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="d"> <xsl:value-of select="concat('toc-item-',$ThisDocument//ntw:nums[@num=$Brac]/@word,'-level')"/> </xsl:variable> <table class="{$d}"> <tbody> <tr> <td class="toc-item-num"> <xsl:value-of select="@num"/> </td> <td class="toc-title"> <xsl:apply-templates select="node() except child::footnote"/> </td> <td class="toc-pg"> <a href="{$tocpgtag}"> <xsl:value-of select="descendant::phrase[1]"/><![CDATA[ ]]> </a> </td> </tr> </tbody> </table> </xsl:if> </xsl:template>
输出是
Non-Hong Kong companies <sup>123</sup> with a place of business in Hong Kong <sup>124</sup>
当我用这个
<xsl:apply-templates select="./title[not(./footnote)]"/>
它没有显示任何东西,预期的输出是,只是
Non-Hong Kong companies with a place of business in Hong Kong
如果还有其他孩子(如内容样式),则应该应用它们,只有
footnote
才会被忽略。请让我知道我该怎么做。
谢谢
I've the below XML in my XSLT.
<section level="sect4" number-type="manual" num="(ii)"> <title> Non-Hong Kong companies <footnote num="123"> <para>The venerable statutory .</para> </footnote> with a place of business in Hong Kong <footnote num="124"> <para>It may be noted in this context of English judgments.</para> </footnote> </title> <para> <phrase>3.039</phrase> Companies incorporal Companies, <footnote num="125"> <para>Registration of the information specified in this section must be effected</para> </footnote> of which three are relevant for present purposes: </para> </section>
here i want to apply-templates but ignore the footnotes, when i use the below.
<xsl:template name="IndexItem"> <xsl:if test="not(contains(@level,'sect1'))"><!--changed fron @num to sect2--> <xsl:variable name="tocpg"> <xsl:value-of select="concat('#P',descendant::phrase[1])"/> </xsl:variable> <xsl:variable name="nu"> <xsl:number format="(i)"/> </xsl:variable> <xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/> <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/> <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="text" select="current()/title/text()"/> <xsl:variable name="Brac"> <xsl:choose> <xsl:when test="contains(current()/@num,$nu)"> <xsl:value-of select="3"/> </xsl:when> <xsl:when test="contains(current()/@num,'(')"> <xsl:value-of select="2"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="1"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="d"> <xsl:value-of select="concat('toc-item-',$ThisDocument//ntw:nums[@num=$Brac]/@word,'-level')"/> </xsl:variable> <table class="{$d}"> <tbody> <tr> <td class="toc-item-num"> <xsl:value-of select="@num"/> </td> <td class="toc-title"> <xsl:apply-templates select="node() except child::footnote"/> </td> <td class="toc-pg"> <a href="{$tocpgtag}"> <xsl:value-of select="descendant::phrase[1]"/><![CDATA[ ]]> </a> </td> </tr> </tbody> </table> </xsl:if> </xsl:template>
the output is
Non-Hong Kong companies <sup>123</sup> with a place of business in Hong Kong <sup>124</sup>
and when i use this
<xsl:apply-templates select="./title[not(./footnote)]"/>
it is not displaying anything, the expected output is, just
Non-Hong Kong companies with a place of business in Hong Kong
and also if there are anymore other childs(like content style), they should be applied, only
footnote
is to be ignored.please let me know how can i do this.
Thanks
原文:https://stackoverflow.com/questions/24990521
最满意答案
http://www.w3.org/TR/css3-values/#lengths
CSS中最接近的单位是视口百分比单位。
- vw - 等于初始包含块的宽度的1%。
- vh - 等于初始包含块的高度的1%。
- vmin - 等于vw或vh中的较小者。
- vmax - 等于vw或vh中的较大者。
Opera唯一不知道的移动浏览器不支持这些单元。 http://caniuse.com/#feat=viewport-units
http://www.w3.org/TR/css3-values/#lengths
The closest unit available in CSS are the viewport-percentage units.
- vw - Equal to 1% of the width of the initial containing block.
- vh - Equal to 1% of the height of the initial containing block.
- vmin - Equal to the smaller of vw or vh.
- vmax - Equal to the larger of vw or vh.
The only mobile browser to be aware of that doesn't support these units is Opera. http://caniuse.com/#feat=viewport-units
相关问答
更多-
注意:上述广泛使用的解决方案是基于displayMetrics.density 。 但是,文档解释说这个值是一个四舍五入的值,与屏幕“buckets”一起使用。 例如。 在我的Nexus 10上,它返回2,其中实际值将是298dpi(实际)/ 160dpi(默认)= 1.8625。 根据您的要求,您可能需要精确的转换,可以实现这一点: [编辑]这并不意味着与Android的内部dp单元混合,因为这当然还是基于屏幕桶。 使用这个,你想要一个应该在不同的设备上呈现相同的真实尺寸的单元。 将dp转换为像素: pu ...
-
Android:宽度为160dp等于屏幕宽度的100%?(Android : is a width of 160dp equals to 100% of the screen width?)[2022-02-01]
160号dp是1英寸(或非常接近)。 他们所说的是如果你有一个160 dpi(每英寸点数)的设备,那么1像素= 1dp。 在Android的早期,160 dpi很常见。 No. 160 dp is 1 inch (or extremely close). What they're saying is if you had a 160 dpi (dot per inch) device, then 1 pixel=1dp. 160 dpi was common in the early days of And ... -
http://www.w3.org/TR/css3-values/#lengths CSS中最接近的单位是视口百分比单位。 vw - 等于初始包含块的宽度的1%。 vh - 等于初始包含块的高度的1%。 vmin - 等于vw或vh中的较小者。 vmax - 等于vw或vh中的较大者。 Opera唯一不知道的移动浏览器不支持这些单元。 http://caniuse.com/#feat=viewport-units http://www.w3.org/TR/css3-values/#lengths The c ...
-
以编程方式将LayoutParams的高度设置为与密度无关的像素(Programmatically set height on LayoutParams as density-independent pixels)[2022-07-15]
您需要将dip值转换为像素值: int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,, getResources().getDisplayMetrics()); 对我而言,这是一个伎俩。 You need to convert your dip value into pixels: int height = (int) TypedValue.applyDimension(TypedValue.C ... -
Android,以dp为单位设置宽度和高度(Android and setting width and height programmatically in dp units)[2023-10-01]
您将不得不使用显示比例因子将其从dps转换为像素。 final float scale = getContext().getResources().getDisplayMetrics().density; int pixels = (int) (dps * scale + 0.5f); You'll have to convert it from dps to pixels using the display scale factor. final float scale = getContext().g ... -
Android DP到PX的转换,是mdpi上160 dp总是160 px?(Android DP to PX conversion, is 160 dp always 160 px on mdpi?)[2022-11-10]
根据Dianne Hackborn的这篇文章 ,情况确实如此。 “兼容”的Android设备不能具有非标准密度: 从理论上讲,Android可以扩展到任何密度,并显示其UI以匹配屏幕的精确密度。 在实践中,我们不这样做 - 我们已经定义了一些我们支持的特定密度,并要求兼容设备坚持它们 。 为什么是这样? 第一个原因只是为了帮助我们的开发人员。 UI设计师倾向于制作漂亮干净的图形; 这些图形被绘制为位图,并为设计人员提供一小组目标位图大小,以支持而不是无限变化,使事情变得更加简单。 (......) 因此An ... -
有一个网站收集有关不同设备的视口大小(即dp的大小)的信息: http://viewportsizes.com/ 大多数手机纵向有320和360 dp宽度,大多数7"平板电脑纵向最width 600 dp ,大多数10"平板电脑最短width 720 dp 。 There is a website which collects information about viewport sizes (i. e. sizes in dp) of different devices: http://viewports ...
-
实际像素大小是基于dp计算的,但不如公式dp = px /(dpi / 160)那样精确。 实际上,它首先确定屏幕密度(ldpp,mdph,hdpi,xhdpi,xxhdpi,xxxhdpi)并使用该密度从{0.75,1.0,1.5,2.0,3.0,(4.0)}获得一个比率。 在你的情况下,系统将386dpi视为xxhdpi,因此它通过乘以3.0来计算该值,而360dp将精确地填充屏幕的宽度(1080p) The actual pixel size is calculated based on dp, bu ...
-
是否有类似缩放/缩放独立像素的`rem`单位?(is there something like `rem` units for zoom/scale independent pixels?)[2022-01-22]
他们并不完全是“rpx”,但也许你正在寻找像vw和vh这样的东西? They're not exactly "rpx", but maybe you're looking for something like vw and vh? -
一个好的解决方案是将'dp'设为默认单位而不是像素。 只需打开tiapp.xml字符串'system'或'px'到'dp'...
system 改为dp A good solution is to make 'dp' your default unit instea ...