msambasiva@gmail.com
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by msambasiva@gmail.com
-
-
New bee - XSLT issue
Below is the code snippet for getting required output.
But I've to find out chapter title using on attribute value (linkend="CHAP_1").
In toc, there might be chance of missing chapter reference. In the toc section, if there is no reference for CHAP_3, then expected output should be as below.
XML:
=====
XML:
====
<?xml version = '1.0' encoding = 'UTF-8'?>
<book>
<toc id="TOC">
<title>Contents</title>
<itemizedlist>
<listitem>
<para>
<xref linkend="CHAP_1"/>
</para>
</listitem>
<listitem>
<para>
<xref linkend="CHAP_2"/>
</para>
</listitem>
<listitem>
<para>
<xref linkend="CHAP_4"/>
</para>
</listitem>
</itemizedlist>
</toc>
<chapter id="CHAP_1">
<title>Subject Areas</title>
</chapter>
<chapter id="CHAP_2">
<title>Business Questions</title>
</chapter>
<chapter id="CHAP_3">
<title>Job Roles</title>
</chapter>
<chapter id="CHAP_4">
<title>Duty Roles</title>
</chapter>
</book>
Expected HTML OUTPUT:(third item is missing from toc)
======================================================
Contents
• Subject Areas
• Business Questions
• Duty Roles
Subject Areas
Business Questions
Job Roles
Duty Roles
XSL:
=====
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="book/toc/title" /></title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="book">
<xsl:for-each select="chapter">
<ul>
<li><a href="#{@id}"><xsl:value-of select="title"/></a><br/></li>
</ul>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="chapter">
<xsl:variable name="Id" select="@id"/>
<h2> <a name="{$Id}"><xsl:value-of select="title"/></a></h2>
</xsl:template>
</xsl:stylesheet>
Thanks in advance,
Samba
nonempty check for an element at the same level
in XSLT/XSL-FO
Posted
Hi,
XSLT2.0
I am trying to find the element names and count which are nonempty at any level
Ex:
<custom-data>
<schema>XXXschema>
<object-name>YYYYY</object-name>
<short-name>YYYYY</short-name>
<object-type>TABLE</object-type>
<mls-support-model/>
<object-owner>PPPP</object-owner>
<status/>
<columns>
<columns>
<name>ID</name>
<datatype>NUMBER</datatype>
<length/>
<precision/>
<not-null>Yes</not-null>
<comments>Identifier of the aging bucket.</comments>
<flexfield-mapping/>
<status/>
</columns>
<columns>
<name>LAST_UPDATED_BY</name>
<datatype>VARCHAR2</datatype>
<length>64</length>
<precision/>
<not-null>Yes</not-null>
<comments>Who column: indicates the user who last updated the row.</comments>
<flexfield-mapping/>
<status/>
</columns>
<columns>
<name>ATTRIBUTE8</name>
<datatype>VARCHAR2</datatype>
<length>150</length>
<precision/>
<not-null/>
<comments>Descriptive Flexfield: segment of the user descriptive flexfield.</comments>
<flexfield-mapping>Aging </flexfield-mapping>
<status/>
</columns>
</columns>
</custom-data>
I want to generate a table from the above data. The trick is, if there is no data for a column at any where, we need to exclude that column from the output table.
Ex: status,precision elements is empty for all the columns. SO we don't need to display status and precision column in output table.
How to get the number of elements without data at the same level and there names?
Thanks,
Samba.