By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

CDATA and template matching

P: n/a
I created a simple 7 line stylesheet in XML Spy that is matching certain
elements (table names) used to created some SQL syntax in the result file. I
had to do this for 4 different Elements so I created 4 different
stylesheets. Two of them are working as expected. The other two are printing
out the correct values to the result file but are also including all my
CDATA information from elements that do not match the template match clause.
Any ideas what I am doing wrong? This is my first day using XSLT.

Shannon Hughes
FVBC Webmaster
http://www.fvbaptist.org
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This is my stylesheet below:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="text" encoding="us-ascii" media-type="text/plain"
indent="no" cdata-section-elements=""/>

<xsl:template match="SERVICE_MEASUREMENT">

<xsl:text>DROP TABLE </xsl:text>

<xsl:value-of select="@DB_NAME"/>

<xsl:text>;&#xa;</xsl:text>
</xsl:template>

</xsl:stylesheet>

The "DROP TABLE" string is being copied to the result file correctly but all
the CDATA information from other elements that do not match the template are
also being copied to the result file.

Thanks for your help.
--
Shannon Ray Hughes
sr******@lucent.com
919-463-3166
"Shannon Hughes" <sr*************@earthlink.net> wrote in message
news:hJ*************@newsread1.news.atl.earthlink. net...
I created a simple 7 line stylesheet in XML Spy that is matching certain
elements (table names) used to created some SQL syntax in the result file. I had to do this for 4 different Elements so I created 4 different
stylesheets. Two of them are working as expected. The other two are printing out the correct values to the result file but are also including all my
CDATA information from elements that do not match the template match clause. Any ideas what I am doing wrong? This is my first day using XSLT.

Shannon Hughes
FVBC Webmaster
http://www.fvbaptist.org

Jul 20 '05 #2

P: n/a
This confirms my guess that the unexpected output is result from the
built-in templates.

Either specify empty rules (templates) for the nodes you don't want
processed, or specify explicitly (in the "select" attribute of
xsl:apply-templates) what is to be processed by xsl:apply-templates.

Once again -- do read about built-in templates.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

This is my stylesheet below:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="text" encoding="us-ascii" media-type="text/plain"
indent="no" cdata-section-elements=""/>

<xsl:template match="SERVICE_MEASUREMENT">

<xsl:text>DROP TABLE </xsl:text>

<xsl:value-of select="@DB_NAME"/>

<xsl:text>;&#xa;</xsl:text>
</xsl:template>

</xsl:stylesheet>

The "DROP TABLE" string is being copied to the result file correctly but all
the CDATA information from other elements that do not match the template are
also being copied to the result file.

Thanks for your help.
--
Shannon Ray Hughes
sr******@lucent.com
919-463-3166
"Shannon Hughes" <sr*************@earthlink.net> wrote in message
news:hJ*************@newsread1.news.atl.earthlink. net...
I created a simple 7 line stylesheet in XML Spy that is matching certain
elements (table names) used to created some SQL syntax in the result file.

I
had to do this for 4 different Elements so I created 4 different
stylesheets. Two of them are working as expected. The other two are

printing
out the correct values to the result file but are also including all my
CDATA information from elements that do not match the template match

clause.
Any ideas what I am doing wrong? This is my first day using XSLT.

Shannon Hughes
FVBC Webmaster
http://www.fvbaptist.org


Jul 20 '05 #3

P: n/a
Thanks so much, that did the trick....I forced the apply-templates element:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:output method="text" indent="no" />

<xsl:template match="/">

<xsl:apply-templates select="//SERVICE_MEASUREMENT |
//SUBSCRIBER_MEASUREMENT"/>

</xsl:template>

<xsl:template match="SERVICE_MEASUREMENT | SUBSCRIBER_MEASUREMENT">

<xsl:text>Found it&#xa;</xsl:text>

</xsl:template>

</xsl:stylesheet>
--
Shannon Ray Hughes
sr******@lucent.com
919-463-3166
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.