473,585 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ 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 2807
This is my stylesheet below:

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

<xsl:styleshe et 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>DRO P TABLE </xsl:text>

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

<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.earth link.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:styleshe et 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>DRO P TABLE </xsl:text>

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

<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.earth link.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:styleshe et 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_MEASURE MENT |
//SUBSCRIBER_MEAS UREMENT"/>

</xsl:template>

<xsl:template match="SERVICE_ MEASUREMENT | SUBSCRIBER_MEAS UREMENT">

<xsl:text>Fou nd 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
2344
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 specification. The Problem is what template rule to be used if there are more than one matching template rule. You will find the following:
0
1996
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 been great except for a minor hiccup - all text within CDATA blocks shows up at the end of my output files without being invited. I think I've boiled...
0
2079
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 XSLT processing model: http://www.w3.org/TR/xslt#section-Processing-Model the root node will be processed by a built-in rule, because you do not
2
7068
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 in the form of XHTML in an XML document (which, in turn, is stored in an XML database). So far so good. However the editing tool must allow users to...
3
11859
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 have <!]> in them. I would like to use XSLT to remove the <message> elements whose CDATA (the "...") matches a particular regular expression.
8
12786
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
2251
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
2327
by: Simon Brooke | last post by:
Here's my problem: <xsl:template match="/category"> .... <script type="text/javascript"> &lt;!]&gt; </script> .... </xsl:template>
2
5235
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 reformats the XML to another format (still XML, not HTML). This works fine, but whatever I do, I can't get the finally output section to have CDATA...
0
7835
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8195
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8334
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8209
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5707
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3831
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2340
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 we have to send another system
1
1444
muto222
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.