473,811 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

combining two documents

Hi,

I would like to take two documents and combine them. I can do this but
I'm having a little problem with namespaces again. The input documents
namespace is xhtml, but how do I tell the processor what namespace to
use for the sourced document (the one read by document())?

Just now it outputs

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample </title>
</head>

<body>
<div id="leftcontent ">

<!-- this is the stuff taken from the document menu.xml -->

<body xmlns=""> <===== PROBLEM

<p class="navig-header">
Web
</p>
</body>
</div>
<div id="rightconten t">

<!-- this is taken from the input file specified to the parser -->
<p class="sample-header">
Sample text
</p>

</div>
</body>
</html>
Aside from the fact it outputs the body of the menu.xml document, I
don't want it to output the xmlns="". How can this be done? Can the
result be copied into a variable and the template applied to that?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transfor m version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="ht tp://www.w3.org/1999/xhtml">

<xsl:output
method = "xhtml"
version = "1.0"
omit-xml-declaration = "no"
encoding = "UTF-8"
indent = "yes"
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system =
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<!-- matches root
-->
<xsl:template match="/xhtml:">
<html>
<xsl:apply-templates select="/xhtml:html/head" />
<xsl:apply-templates select="/xhtml:html/body" />
</html>
</xsl:template>

<!-- matches body
-->
<xsl:template match="xhtml:bo dy">
<!-- output <body> <div id="leftcontent "> -->
<xsl:text disable-output-escaping="yes">
&lt;body&gt;
&lt;div id="leftcontent "&gt;
</xsl:text>

<!-- output menu -->
<xsl:apply-templates select="documen t('menu.xml')/html/body" />

<!-- output </div> -->
<xsl:text disable-output-escaping="yes">
&lt;/div&gt;
</xsl:text>
<!-- output <div id="rightconten t"> -->
<xsl:text disable-output-escaping="yes">
&lt;div id="rightconten t"&gt;
</xsl:text>

<!-- output rest of body section -->
<xsl:apply-templates />

<!-- output </div> -->
<xsl:text disable-output-escaping="yes">
&lt;/div&gt;
</xsl:text>

<!-- output </body> -->
<xsl:text disable-output-escaping="yes"> &lt;/body&gt;</xsl:text>
</xsl:template>
<!-- matches anything that isn't covered by a template,
and copies it exactly
-->
<xsl:template match="node()|@ *">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
</xsl:copy>
</xsl:template>
</xsl:transform>

Jul 20 '05 #1
2 1746
Dimitre Novatchev wrote:
There are at least two syntactical/semantic errors in your stylesheet:

<xsl:output
method = "xhtml"

the value of the "method" attribute cannot be 'xhtml'.


It can in XSL 2.0 draft and this is supported by Saxon. However I have
changed this to xml below, it only changes the output indentation.

<xsl:template match="/xhtml:">

This is not a valid match pattern.
Therefore, the code is not the same as the one you are talking about
(because the latter produced result, not error messages).

Please, provide the real code.


The problem has changed after making some changes (fixing the syntax),
it outputs nothing for the second document at all.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transfor m version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="ht tp://www.w3.org/1999/xhtml">

<xsl:output
method = "xml"
version = "1.0"
omit-xml-declaration = "no"
encoding = "UTF-8"
indent = "yes"
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system =
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<!-- matches root
-->
<xsl:template match="xhtml:">
<html>
<xsl:apply-templates select="xhtml:/html/head" />
<xsl:apply-templates select="xhtml:/html/body" />
</html>
</xsl:template>

<!-- matches body
-->
<xsl:template match="xhtml:bo dy">
<!-- output <body> <div id="leftcontent "> -->
<xsl:text disable-output-escaping="yes">
&lt;body&gt;
&lt;div id="leftcontent "&gt;
</xsl:text>

<!-- output menu -->
<xsl:apply-templates select="documen t('menu.xml')"/>

<!-- output </div> -->
<xsl:text disable-output-escaping="yes">
&lt;/div&gt;
</xsl:text>
<!-- output <div id="rightconten t"> -->
<xsl:text disable-output-escaping="yes">
&lt;div id="rightconten t"&gt;
</xsl:text>

<!-- output rest of body section -->
<xsl:apply-templates />

<!-- output </div> -->
<xsl:text disable-output-escaping="yes">
&lt;/div&gt;
</xsl:text>

<!-- output </body> -->
<xsl:text disable-output-escaping="yes"> &lt;/body&gt;</xsl:text>
</xsl:template>
<!-- matches anything that isn't covered by a template,
and copies it exactly
-->
<xsl:template match="node()|@ *">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
</xsl:copy>
</xsl:template>

</xsl:transform>

Also, you didn't provide the two xml documents.


-- Input xhtml given to parser...
--

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample </title>
<link rel="stylesheet " type="text/css" href="sample.cs s" />
</head>
<body>
<p class="sample-header">
Sample text
</p>

<!-- bunch of text -->
<p>
Sample page text
</p>
</body>
</html>
-- file read by document() function
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>menu</title>
</head>
<body>
<p class="navig-header">
Web
</p>
<p class="navig-menu">
<a href="xhtml/index.html">XHT ML</a>
</p>
</body>
</html>
-- Output
--
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Sample </title>

<link rel="stylesheet " type="text/css" href="sample.cs s"/>

</head>

<body>
<div id="leftcontent ">

</div>

<div id="rightconten t">

<p class="sample-header">
Sample text
</p>

<!-- bunch of text -->

<p>
Sample page text
</p>

</div>
</body>
</html>
Thanks,
Chris

Jul 20 '05 #2
Nothing has changed, this:
<xsl:template match="xhtml:">
is an attempt to define a template with invalid match pattern. An error
message to this effect is generated by MSXML4 and JD, other XSLT processors
(Saxon, XalanJ) simply crash.

Could you, please correct this and try again?
=====
Cheers,

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

"chris" <sp**********@n tlworld.com> wrote in message
news:5k******** **********@news fep4-glfd.server.ntl i.net... Dimitre Novatchev wrote:
There are at least two syntactical/semantic errors in your stylesheet:

<xsl:output
method = "xhtml"

the value of the "method" attribute cannot be 'xhtml'.


It can in XSL 2.0 draft and this is supported by Saxon. However I have
changed this to xml below, it only changes the output indentation.

<xsl:template match="/xhtml:">

This is not a valid match pattern.
Therefore, the code is not the same as the one you are talking about
(because the latter produced result, not error messages).

Please, provide the real code.


The problem has changed after making some changes (fixing the syntax),
it outputs nothing for the second document at all.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transfor m version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="ht tp://www.w3.org/1999/xhtml">

<xsl:output
method = "xml"
version = "1.0"
omit-xml-declaration = "no"
encoding = "UTF-8"
indent = "yes"
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system =
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<!-- matches root
-->
<xsl:template match="xhtml:">
<html>
<xsl:apply-templates select="xhtml:/html/head" />
<xsl:apply-templates select="xhtml:/html/body" />
</html>
</xsl:template>

<!-- matches body
-->
<xsl:template match="xhtml:bo dy">
<!-- output <body> <div id="leftcontent "> -->
<xsl:text disable-output-escaping="yes">
&lt;body&gt;
&lt;div id="leftcontent "&gt;
</xsl:text>

<!-- output menu -->
<xsl:apply-templates select="documen t('menu.xml')"/>

<!-- output </div> -->
<xsl:text disable-output-escaping="yes">
&lt;/div&gt;
</xsl:text>
<!-- output <div id="rightconten t"> -->
<xsl:text disable-output-escaping="yes">
&lt;div id="rightconten t"&gt;
</xsl:text>

<!-- output rest of body section -->
<xsl:apply-templates />

<!-- output </div> -->
<xsl:text disable-output-escaping="yes">
&lt;/div&gt;
</xsl:text>

<!-- output </body> -->
<xsl:text disable-output-escaping="yes"> &lt;/body&gt;</xsl:text>
</xsl:template>
<!-- matches anything that isn't covered by a template,
and copies it exactly
-->
<xsl:template match="node()|@ *">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
</xsl:copy>
</xsl:template>

</xsl:transform>

Also, you didn't provide the two xml documents.


-- Input xhtml given to parser...
--

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample </title>
<link rel="stylesheet " type="text/css" href="sample.cs s" />
</head>
<body>
<p class="sample-header">
Sample text
</p>

<!-- bunch of text -->
<p>
Sample page text
</p>
</body>
</html>
-- file read by document() function
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>menu</title>
</head>
<body>
<p class="navig-header">
Web
</p>
<p class="navig-menu">
<a href="xhtml/index.html">XHT ML</a>
</p>
</body>
</html>
-- Output
--
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Sample </title>

<link rel="stylesheet " type="text/css" href="sample.cs s"/>

</head>

<body>
<div id="leftcontent ">

</div>

<div id="rightconten t">

<p class="sample-header">
Sample text
</p>

<!-- bunch of text -->

<p>
Sample page text
</p>

</div>
</body>
</html>
Thanks,
Chris

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11734
by: Andrew Dixon - Depictions.net | last post by:
Hi Everyone. I have been working on some code that strips the HTML code out of an HTML page leaving just the text on the page. At the moment this is what I have: // Strip all tags replacePattern = "<(.|\n)+?>"; pageHTML = pageHTML.replaceAll(replacePattern,""); //Remove any HTML specific characters (e.g. &quot; or &amp;)
6
4987
by: Alan | last post by:
I'm just about to start a project that needs to combine the results of a SQL Server query with the results of an Index Server query. The basic idea is that the user enters/selects a bunch of search criteria on a form. Most of the criteria selected by the user will be used to select records from the database - standard WHERE clause stuff - but the user can also enter free-text that should be searched for in associated uploaded documents. The...
2
3277
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491 (Internationalized Domain Names / IDNA) which is something that I also need to support. The problem that I've been struggling with in .NET is that of Unicode Code Points > 0xFFFF. These points are encoded into UTF8 using the Surrogate Pair encoding scheme that...
7
4822
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following capital letters all work correctly - B C D F G M S T with the diacritical marker &#_0775. Why am I having a problem with P?
6
10714
by: Alvo von Cossel I | last post by:
hi, i have tried to create text where you move yor mouse over it and it underlines itself. this, however, takes far too long. is there a way around this or can you create css documents that do the underlining? -- Alvo von Cossel I of Germany
0
1490
by: DavidGeorge | last post by:
I have an application with a number of reports, some in Landscape, some in Portrait orientation. I need to be able to select each of these reports separately at times. However, at the end of each month I need to be able to create sets of three different reports to send to clients, ideally as a single report. I had thought of making the second and third reports as subreports of the first report but the mixup of paper orientations is a...
7
12836
by: HP17 | last post by:
I’m able using Javascript to transform a XML file using XSLT to a nice HTML output. What I need to do now is to combine two XML files and transform them together using XSLT. Here an abstract example: Load(xml1); Load(xml2); Xml = xml1 + xml2; Xml.transformNode(xslt); In my xslt document I need to access then nodes from both xml documents therefore the combination (the select=”document(myXML)” in xslt is to late since I can’t use a path...
3
7921
by: =?Utf-8?B?U1MgbWFkaHU=?= | last post by:
Hi, I have two word files. listprice.doc,product.doc I converted each of the documents into bytes byte bytedata - lisprice.doc byte bytedata1-product.doc I create a new array and copy both the contents in it and upload it to a file in d: I am getting only the lisprice.doc document in D:\File.doc,I am not getting
5
5645
by: Tristan Miller | last post by:
Greetings. Is it possible using HTML and CSS to represent a combining diacritical mark in a different style from the letter it modifies? For example, say I want to render Å‘ (Latin small letter o with a double acute accent), but with the o in black and the double acute accent in green. Are either of the following valid? 1. <span style="color: black;">o</span><span style="color: green;">&#x030B;</span>
0
9728
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10389
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
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
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.