XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 1st, 2003, 04:40 PM
aragon
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
XSLT: Namespace problems

Hi,

I have two problems...

1. How do you differentiate the same elements in two documents with the same namespace? I want to combine the bodies of two XHTML documents, but can't figure out how to reference the body element of the other document... It's read with the document function, but it won't apply the template because I don't know how to specify it here. Assuming this could be resolved how do you stop it infinitely recursing?

The stylesheet should take the input file given to the parser dump it between the second div element and another from the document function and dump that between the first div element.

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

<xslutput 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"/>


<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="xhtml:html">
<html>
<xsl:copy-of select="xhtml:head"/>
<xsl:apply-templates select="xhtml:body"/>
</html>
</xsl:template>


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

<!-- *** copy body of full.xml *** -->
<div id="leftcontent">
<xsl:apply-templates select="document('full.xml')/html/body"/>
</div>

<!-- *** copy body of xml doc given to parser *** -->
<div id="rightcontent">
<xsl:apply-templates/>
</div>
</body>
</xsl:template>

<xsl:template match="node()|@*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:transform>


2. The first problem encountered was with the inclusion of the doctype in the source file caused no output. This was remedied by including the xhtml namespace, but this appears in the html element output as an attribute... is there anyway to remove this? An xmlns attribute also appeared in the elements taken from the file read by the document function during testing (it output because it wasn't html, just some random xml for testing purposes).

<?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" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<head>

<title>hi</title>

</head>
<body>

<!-- no output -->
<div id="leftcontent"/>

<!-- this div contains a copy of the contents of body element in the file given to parser -->
<div id="rightcontent">

<p>bye</p>

</div>
</body>
</html>


Any help is appreciated,
Aragon

Last edited by aragon : August 1st, 2003 at 04:45 PM.

Reply With Quote
  #2  
Old August 2nd, 2003, 04:19 PM
aragon
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Ok, I sorted the first problem... an examples is posted for reference.

The namespace comes after the document function, like so...

<xsl:template match="xhtml:body">
<xslaram name="main">yes</xslaram>
<xsl:choose>
<xsl:when test="$main='yes'">
<xsl:apply-templates select="document($leftDocument)/xhtml:html/xhtml:body">
<xsl:with-param name="main">no</xsl:with-param>
</xsl:apply-templates>
<div id="rightcontent">
<xsl:apply-templates />
</div>
</xsl:when>
<xsltherwise>
<div id="leftcontent">
<xsl:apply-templates />
</div>
</xsltherwise>
</xsl:choose>
</xsl:template>

Still stuck with the second one though... it outputs

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

I want it to output

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

or

<html>


Cheers,
Aragon

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSLT: Namespace problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway