Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Pick/Choose XML from XSL

From: Prab_kar@-------.--- (-----)
To: NULL
Date: 12/1/2004 2:03:00 PM
Hello all,
I want to HTML-ize an .xml (Test.xml) file and am running into a
problem with my XSL file.

The .xml contains info about each tag, called 'targets' and each
target has a message with certain priority. I want to bundle all these
targets in a top-area which have "a href" links to the details section
down below. Also, I want to ignore messages with 'debug' priority and
print only the 'info' priority messages.


Test.xml:
==========================X M L==================================
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="Test.xsl"?>

<main>
  <target name="TargetOne">
    <task>
	<message priority="info"><![CDATA[Info about Target One]]></message>
    </task>
  </target>

  <target name="TargetTwo">
    <task>
	<message priority="debug"><![CDATA[Info about Target Two: Ideally I
shouldnt be displayed!!]]></message>
    </task>
  </target>

  <target name="TargetThree">
    <task>
      	<message priority="info"><![CDATA[Info about Target Three]]>
</message>
    </task>
  </target>

</main>

==========================X M L==================================



I've gotten this far with my .xsl:

==========================X S L==================================

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>

<xsl:template match="main">
	<html>
    	<body>

      	<!-- make header links -->
      	<xsl:for-each select="target">
		<xsl:if test="@name='TargetOne'
			or @name='TargetTwo'
			or @name='TargetThree'">
       		<a href="#{generate-id()}"> <xsl:value-of select="@name"/>
</a>
       		<br/>
		</xsl:if>
      	</xsl:for-each>

      	<hr/>
      	<!-- show the targets, tasks and messages -->
      	<xsl:apply-templates select="target"/>

        </body>
	</html>

</xsl:template>


<xsl:template match="target">
	<xsl:if test="@name='TargetOne'
		or @name='TargetTwo'
		or @name='TargetThree'">
  	<a name="{generate-id()}"/>
	</xsl:if>

	<h4>
    	<xsl:text>Target: </xsl:text>
    	<xsl:value-of select="@name"/>
	</h4>

  	<!-- show the messages -->
  	<xsl:apply-templates select="task"/>
</xsl:template>

</xsl:stylesheet>
==========================X S L==================================

I can now print the desired HTML with targets bundled up in a top-area
with links to details down below. But, I'm unable to ignore/discard
the 'debug' messages. I'm trying to use '<xsl:template
match="message[@priority] != 'debug'
but it doesn seem to work, the Target Two is always being printed.

Could anyone give me pointers on how to go about this, please?

Thanks for your time,
Prabh


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent