Hi Jaya,
In your template
<xsl:template match="Attribute">
<xsl:text>Field</xsl:text>,<xsl:value-of select="@name"/>, <xsl:value-of
select="@ReleaseIntroduced"/>, <xsl:value-of select="@ReleaseChanged"/>
<xsl:value-of select="."/> <!-- THIS INSTRUCTION -->
<xsl:apply-templates/>
</xsl:template>
The instruction <xsl:value-of select="."/> is copying the string value of
the context node (the <Attribute>) to the result. (The string value of a
node is the concatenation of all its text node descendants: that is, all
the text inside it.)
If you don't want this, remove it. If you want something else and don't
know how to get it, please ask again.
It seems to me that you aren't yet fully clear on how XSLT goes about
generating output from the input -- how templates are applied and what the
different instructions ("commands") in them do. If you feel you're still
mystified by this, some time studying up on the XSLT processing model might
be well spent. Another thing you could try -- particularly if you learn by
doing more than by studying -- is commenting out each of the instructions
inside this template (or another) in turn, and looking at how each such
change affects your output. To the extent you're surprised by the results
(that is, to the extent your guess about what will happen turns out to be
wrong), that's an indication that you don't really understand what each
instruction does.
Naturally, knowing what each instruction does is the key to being able to
control your code.... :->
Cheers,
Wendell
At 02:57 PM 10/24/2003, you wrote:
Thanks but I am still getting the text associated with units in the
output. Also
text in descr and default nodes are coming in output too.
Here is the xsl with your suggestions: I do not want the text in <descr>,
<units>,
<default> nodes. All these are child nodes
of <Attribute> entity.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output omit-xml-declaration="yes"
indent="no" encoding="iso-8859-1" />
<xsl:template match="objType">
<xsl:text>ObjType</xsl:text>,<xsl:value-of
select="@name"/>,<xsl:value-of
select="@ReleaseIntroduced"/>,<xsl:value-of select="@ReleaseChanged"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Attribute">
<xsl:text>Field</xsl:text>,<xsl:value-of select="@name"/>,
<xsl:value-of
select="@ReleaseIntroduced"/>, <xsl:value-of select="@ReleaseChanged"/>
<xsl:value-of select="."/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="units"/>
<xsl:template match="default"/>
<xsl:template match="descr"/>
<xsl:template
match="*[self::objType or self::Attribute]
[not(@ReleaseChanged = 7
or
@ReleaseIntroduced = 7
)
] "/>
</xsl:stylesheet>
thanks
jaya
Wendell Piez wrote:
> At 01:41 PM 10/23/2003, you wrote:
> >Thanks . That worked! However I am getting all the default text nodes
printed
> >out. The text in "default" and "units" node is printing out. I have
template
> >match defined (for units and default ) but its still printing
"degrees" and
> >"unspecified"
> >in the output. Is it possible to have a single rule that will
eliminate the
> >default behaviour of printing text nodes. ? Thanks!
>
> It is, but you don't want to use it -- it will affect the way text nodes
> are handled in general, whereas you only want to suppress particular text
> nodes.
>
> If you want to suppress the contents of <units>, for example, match it with
> an empty template, as in
>
> <xsl:template match="units"/>
>
> which says "when a units element is matched, do nothing with it".
>
> Instead, you have
>
> <xsl:template match="units">
> <xsl:apply-templates/>
> </xsl:template>
>
> which says "when a units element is matched, apply templates to its
> children" -- whereas you are now telling us you don't want to see the
children.
>
> Remove the apply-templates instruction and the children (in this case the
> text node inside <units>) won't be matched or processed, and won't appear
> in the output.
>
> Cheers,
> Wendell
>
> >Here is a part of xml
> >
> > <Attribute name="restrictThroughputAfterRmax" label="Restrict
Throughput
> >After Reaching Rmax" ReleaseIntroduced="7">
> > <descr/>
> > <type t="RestrictAfterRmax"/>
> > <default>Unspecified</default>
> > <units>degrees</units>
> > </Attribute>
> >
> >XSL Below----
> >
> >?xml version="1.0"?>
> ><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >version="1.0">
> ><xsl:output omit-xml-declaration="yes" indent="no" encoding="iso-8859-1"
> >/>
> ><xsl:template match="objType">
> > <xsl:value-of select="@name"/>,<xsl:value-of
> >select="@ReleaseIntroduced"/>,<xsl:value-of select="@ReleaseChanged"/>
> > <xsl:apply-templates/>
> > </xsl:template>
> >
> ><xsl:template match="Attribute">
> > <xsl:apply-templates/>
> > <xsl:value-of select="@name"/>, <xsl:value-of
> >select="@ReleaseIntroduced"/>, <xsl:value-of select="@ReleaseChanged"/>
> > <xsl:value-of select="."/>
> > </xsl:template>
> >
> ><xsl:template match="units">
> > <xsl:apply-templates/>
> ></xsl:template>
> >
> ><xsl:template match="default">
> > <xsl:apply-templates/>
> ></xsl:template>
> >
> > <xsl:template
> > match="*[self::objType or self::Attribute]
> > [not(@ReleaseChanged = 7
> > or
> > @ReleaseIntroduced = 7
> > )
> > ] "/>
> ></xsl:stylesheet>
> >
> >
> >
> >Dimitre Novatchev wrote:
> >
> > > In the template matching "objType" you have to allow that the templates
> > > matching and applying process should continue.
> > >
> > > As is now, no "Attribute" elements are processed because they
happen to be
> > > descendents of "objType".
> > >
> > > So you have to add:
> > >
> > > <xsl:apply-templates/>
> > >
> > > at the end of the code of the template matching "objType".
> > >
> > > =====
> > > Cheers,
> > >
> > > Dimitre Novatchev.
> > > http://fxsl.sourceforge.net/ -- the home of FXSL
> > >
> > > "jayanti" <jayanti(_at_)watchmark(_dot_)com> wrote in message
> > > news:3F96FF56(_dot_)2F6F146E(_at_)watchmark(_dot_)com(_dot_)(_dot_)(_dot_)
> > > > Hi,
> > > > My xml is listed below.
> > > >
> > > > <?xml version = '1.0' encoding = 'utf-8'?>
> > > > <DB1xEV-DO>
> > > > <typedef .....
> > > > .......
> > > >
> > > > </typedef>
> > > > <objType name="Cell" label="BTS" ReleaseIntroduced="1"
> > > > ReleaseChanged="7">
> > > > <Description>This is the description</Description>
> > > > <Attribute name="CellSiteId" label="BTS ID"
ReleaseIntroduced="1"
> > > > ReleaseChanged="7">
> > > > ...
> > > > </Attribute>
> > > > <Attribute name="btsName" label="BTS Name"
ReleaseIntroduced="7">
> > > >
> > > > ....
> > > > </Attribute>
> > > > <Attribute name="constantPilot" label="Constant Pilot Mode"
> > > > ReleaseIntroduced="1">
> > > > ......
> > > > </Attribute>
> > > > <Attribute name="idleModeGain" label="Idle Mode Gain"
> > > > ReleaseIntroduced="1">
> > > > <descr/>
> > > > </Attribute>
> > > > </objType>
> > > > </DB1xEV-DO>
> > > >
> > > > -- xsl is below---
> > > >
> > > > <?xml version="1.0"?>
> > > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > > > version="1.0">
> > > > <xsl:output omit-xml-declaration="yes" indent="no"
> > > > encoding="iso-8859-1" />
> > > > <xsl:template match="objType">
> > > > <xsl:value-of select="@name"/>,<xsl:value-of
> > > > select="@ReleaseIntroduced"/>,<xsl:value-of
select="@ReleaseChanged"/>
> > > > </xsl:template>
> > > >
> > > > <xsl:template match="Attribute">
> > > > <xsl:value-of select="@name"/>, <xsl:value-of
> > > > select="@ReleaseIntroduced"/>, <xsl:value-of
select="@ReleaseChanged"/
> > > > >
> > > > <xsl:value-of select="."/>
> > > > </xsl:template>
> > > >
> > > > <xsl:template
> > > > match="*[self::objType or self::Attribute]
> > > > [not(@ReleaseChanged = 7
> > > > or
> > > > @ReleaseIntroduced = 7
> > > > )
> > > > ] "/>
> > > > </xsl:stylesheet>
> > > >
> > > >
> > > > My problem is that the above xsl produces only the objType
attributes in
> > > >
> > > > the output not the attributes. Why is that ? and how can I get an
output
> > > >
> > > > that looks like the following:
> > > > objType = Cell
> > > > AttributeName = CellSiteID
> > > > AttributeName = BtsName
> > > > .etc...
> > > >
> > > > thanks in advance
> > > > j
> > > >
> > > >
> > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> > > >
> > > >
> > >
> > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> >
> >
> > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
> ======================================================================
> Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
> Mulberry Technologies, Inc. http://www.mulberrytech.com
> 17 West Jefferson Street Direct Phone: 301/315-9635
> Suite 207 Phone: 301/315-9631
> Rockville, MD 20850 Fax: 301/315-8285
> ----------------------------------------------------------------------
> Mulberry Technologies: A Consultancy Specializing in SGML and XML
> ======================================================================
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list