|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
It doesn't get any simpler than this.
I'm really struggling with XSL, so I've gone back to trying to understand the very basics. I have an XML file in it with names, address, etc, and when I do the following, in addition to "telephone" coming back with the bracketed elements, which I want, ALL the other content of the source XML file is coming back as text. Why? Aren't I just asking it to match "telephone"?
<?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl utput method="xml" indent="yes" /><xsl:template match="telephone"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> |
|
#2
|
|||
|
|||
|
template calling
templates
=============== 1. if u use "match" template <xsl:template match="telephone"> u have to use apply template <xsl:apply-templates select="//telephone"/>- to apply the template as shown below in the example (or) 2. if u use - <xsl:template name="telephone"> u have to use <xsl:call-template name="telephone"/> ==================== <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xslutput method="xml" indent="yes" /> <xsl:template match="/"> <xsl:apply-templates select="//telephone"/> </xsl:template> <xsl:template match="//telephone"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> =========== hope fully this is what u required..however if u give xml .. also it can be explained easily... thank u with regards niha |
|
#3
|
|||
|
|||
|
frank - provide ur xml also
hi frank
provide ur xml also ..so that i can try to figure it out. bcoz it is bit unclear to give correct solution thank u niha |
|
#4
|
|||
|
|||
|
templates
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="yes" encoding="UTF-8" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/><xsl:template match="/"> <xsl:apply-templates select="//telephone"/> </xsl:template> <xsl:template match="telephone"> <xsl:value-of select="."/> <br/> </xsl:template> </xsl:stylesheet> ============================ hope the above code helps u as far as i know... even u match the template... u have to apply the template with relevant tag - as shown above hope that is what u r looking for with regards niha |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > It doesn't get any simpler than this. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|