using apache fop, want collect info in pdf file. xml source has child nodes e, let's say
<node> <a>some val</a> <b>some other val</b> <c>more val</c> <d>even more val</d> <e>a last val</e> </node>
i don't want display of them. a,b,c shall displayed may emtpy. maximum amount of displayed values 3. so, d , e optional , must kept in order.
sadly, xml structure cannot modified.
what right xslt that? tried
<xsl:for-each select="child::*[name()='a' or name() = 'b' or name() = 'c' or name() = 'd' or name() = 'e'][string-length(.)>0]"> <xsl:if test="position() <= 3"> <xsl:value-of select="name()"/> </xsl:if> </xsl:for-each>
but doesn't bring me ordered list. :(
<xsl:sort />
should hep.
in case be:
<xsl:sort select="name()"/>
therefore try:
<xsl:for-each select="child::*[name()='a' or name() = 'b' or name() = 'c' or name() = 'd' or name() = 'e'][string-length(.)>0]"> <xsl:sort select="name()"/> <xsl:if test="position() <= 3"> <xsl:value-of select="name()"/> </xsl:if> </xsl:for-each>
update: because in real live input xml there not useful information sort may add meta information. store meta information depend on capabilities of xslt processor.
if can use node-set() extension may try this:
add variable stylesheet expected order.
xsl:variable name="myorder"> <order name="a" pos="1" /> <order name="b" pos="3" /> <order name="c" pos="2" /> <order name="d" pos="4" /> <order name="e" pos="5" /> </xsl:variable>
make variable usable node-set by:
<xsl:variable name="order" select="exsl:node-set($myorder)" />
sort of variable.
<xsl:sort select="$order/order[@name= name(current())]/@pos"/>
Comments
Post a Comment