Click to See Complete Forum and Search --> : Include element from external XML file


Jills2000
02-22-2004, 11:15 PM
Hi,

I am new to XML/XSL technology so any help here would be really appreciated!

I am creating a HTML document from XML and XSL documents through the use of Saxon XSLT tool. I am having trouble inserting the contents of a specified element from the XML document at the bottom of the generated HTML file.

To clarify, here is the XML code:

**************************************
* StreamStatusMessage.xml
**************************************
<?xml version="1.0" ?>
<StreamStatusMessage>
<Stream>
<Name>GL Daily</Name>
<Message>GL Message</Message>
<LastModified>25/2/2004</LastModified>
</Stream>
<Stream>
<Name>AM Daily</Name>
<Message>AM Message</Message>
<LastModified>28/1/2004</LastModified>
</Stream>
</StreamStatusMessage>


So, I would like to grab the contents of the <Message> element from the first <Stream> node (ie, "GL Message") and insert it at the bottom of my generated HTML document. The way I am currently doing this is not working... here is the (wrong!) XSL document I currently have:

**************************************
* StatusStream.xsl
**************************************

<?xml version="1.0"
encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:template match="/">

<html>
<body>
<xml id="MOTD" src="StreamStatusMessage.xml"></xml>
<span datasrc="#MOTD" datafld="Stream[1]/Message">
</span>
</body>
</html>

</xsl:template>
</xsl:stylesheet>

If anyone could shed a bit of light it would be really helpful. I'm a complete novice at XSL. :confused:

Thanks!
Jill

crh3675
03-02-2004, 04:08 PM
<?xml version="1.0"
encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:template match="/">

<html>
<body>
<xsl:value-of select="Stream/Message"/>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

Hp108
03-13-2004, 06:58 AM
Just a suggestion - if you are new with xsl/xml, then a good xml/xsl editor would help - personally I use cooktop <http://www.xmlcooktop.com/> , it is free, and has saved me many a headaches. Good Luck!