473,473 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CDATA and template matching

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
3 2794
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joachim Spoerhase | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I am a XSLT-beginner and i read the XSLT-recommendation of the W3C through. But I did'nt really understand section 5.5 of the latest...
0
by: Isaac Councill | last post by:
Hello, This seems like a newbie question, but I couldn't find the answer on google. I've been using xsl to transform rdf files into runnable programs in another (non-markup) language. It's...
0
by: Dimitre Novatchev | last post by:
You seem to be unaware of the xslt processing which uses the built-in rules in the absence of templates that match some selected node. http://www.w3.org/TR/xslt#built-in-rule According to the...
2
by: Dave Matthews | last post by:
Hi folks, I'm writing a web-page editing tool for my company which will allow staff (with no "technical" expertise) to maintain their own Intranet sites. The content for each webpage is stored...
3
by: Edwin G. Castro | last post by:
Hi, I'm new to XSLT and I'm having a hard time figuring out whether XSLT will do what I need it to do. I have a XML file with a whole bunch of <message> elements. These <message> elements...
8
by: Tjerk Wolterink | last post by:
Hello all, I've a problem: i've an xsl file that has a template that contains the following: <script type="text/javascript"> <!]>> </script>
4
by: troppfigo | last post by:
I have this example of xml <?xml version="1.0"?> <xml> <!]> </xml> I want to extract the contained data from <body> tag using an xslt transformation. I want to obtain this
10
by: Simon Brooke | last post by:
Here's my problem: <xsl:template match="/category"> .... <script type="text/javascript"> &lt;!]&gt; </script> .... </xsl:template>
2
by: Steveino | last post by:
Hello, Just wondering if anyone could shed any light on this, it's probably me just being silly... I have a dataset that I've used to create an XmlDataDocument, in order to apply XSL. The XSL...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.