Two questions about XSLT -


i have 2 questions xslt.

first, want describe of elements without attribute. like

<element id="p0" attribute="a1"/> <element id="p1"/> <element id="p2"/> 

i need group of elements without attribute="a1", need p1 , p2. xslt, should write <xsl:if test="element[@attribute]=''">? because when test it, found doesn't work. please me.

the second is, want make output result not in same line. like

right:

t11  t22  t33 

wrong:

t11t22t33 

which xslt word should write? bunch.

  1. all relative paths in xsl:template evaluated against node matched template. <xsl:if test="element[@attribute]=''"> testing presence of child of current node called element matches condition. if test located in template matches element nodes, it's not going work. should use . refer current node.

  2. the boolean expression element[@attribute]='' looking element node has attribute called attribute , empty. doesn't test content of attribute attribute.

basically, need understand following template:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">     <xsl:output omit-xml-declaration="yes" indent="yes" />     <xsl:strip-space elements="*"/>     <xsl:template match="element">         <xsl:text>element position=[</xsl:text>         <xsl:value-of select="count(preceding-sibling::element) + 1"/>         <xsl:text>] / </xsl:text>         <xsl:choose>             <xsl:when test=".[not(@attribute)]">                 <xsl:text>no @attribute</xsl:text>             </xsl:when>             <xsl:when test=".[@attribute='']">                 <xsl:text>empty @attribute</xsl:text>             </xsl:when>             <xsl:otherwise>                 <xsl:text>non-empty @attribute</xsl:text>             </xsl:otherwise>         </xsl:choose>         <xsl:text>&#xa;</xsl:text>     </xsl:template> </xsl:stylesheet> 

applied test document:

<root>     <element id="p0" attribute="a1">one</element>     <element id="p1" attribute="test"></element>     <element id="p1" attribute=""></element>     <element id="p2">three</element> </root>  element position=[1] / non-empty @attribute element position=[2] / non-empty @attribute element position=[3] / empty @attribute element position=[4] / no @attribute 

this template answers second question newlines.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -