XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 April 11th, 2011, 03:50 AM
_gabe_ _gabe_ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 5 _gabe_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 42 m 12 sec
Reputation Power: 0
embed xsl

split from http://forums.devshed.com/showthread.php?t=77694 --requinix

Hello I'm new to this Forum!

I'm currently also trying to embed XSL directly into an XML file - so far so good. I also tried the examples mentioned above. My problem is the following. But first the sample code here:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='#test'?>
<!DOCTYPE target [<!ATTLIST xsl:stylesheet id ID #REQUIRED>]>
<target xmlns="urn:asdf">
  <xsl:stylesheet id="test" xmlns:n1="urn:asdf" version="1.0" xmlns:xsl="W3 XSL Transformation">     
  <xsl:output method="html"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:value-of select="n1:target/n1:title"/>          
        </title>
      </head>
      <body>
        <h1>
          <center>
            <xsl:value-of select="n1:target/n1:title"/>            
          </center>
         </h1> 
       </body>
     </html>
    </xsl:template>
    <xsl:template match="xsl:stylesheet"/>
  </xsl:stylesheet>
  <title>This is the title</title>
</target>


The example works fine in Safari 5 but not in Firefox 4. Well in Firefox it shows "This is the title" twice, but without formatation. Interestingly, if I remove the xmlns="urn:asdf" and xmlns:n1="urn:asdf" everthing works quite fine - in Safari and Firefox. However nothing is presented if I write xmlns="urn:asdf" in the target-Tag and the xsl:stylesheet-Tag.

Anyway why is it necessary to define xmlns for the XML and the XSL even if it's the same? Why do I have to add ":n1" for the xmlns in the stylesheet? And why is there no problem at all, when I remove both xmlns instructions?

I would be grateful for any help. Thank you.

_gabe_

Last edited by requinix : April 11th, 2011 at 03:52 PM.

Reply With Quote
  #2  
Old April 11th, 2011, 01:18 PM
xml-profi xml-profi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 190 xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 7 h 8 m 25 sec
Reputation Power: 48
Send a message via ICQ to xml-profi
Problem is namespace

Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='#test'?>
<!DOCTYPE n1:target [
	<!ELEMENT xsl:value-of EMPTY>
<!ATTLIST xsl:value-of
	select CDATA #FIXED "n1:target/n1:title"
>
<!ELEMENT xsl:template ((html))>
<!ATTLIST xsl:template
	match CDATA #FIXED "/"
>
<!ELEMENT xsl:stylesheet ((xsl:output, xsl:template))>
<!ATTLIST xsl:stylesheet
	id CDATA #FIXED "test"
	version CDATA #FIXED "1.0"
	xmlns:n1 CDATA #FIXED "urn:asdf"
	xmlns:xsl CDATA #FIXED "http://www.w3.org/1999/XSL/Transform"
>
<!ELEMENT xsl:output EMPTY>
<!ATTLIST xsl:output
	method CDATA #FIXED "html"
>
<!ELEMENT title ((xsl:value-of))>
<!ELEMENT n1:title (#PCDATA)>
<!ELEMENT n1:target ((xsl:stylesheet, n1:title))>
<!ATTLIST n1:target
	xmlns:n1 CDATA #FIXED "urn:asdf"
>
<!ELEMENT html ((head, body))>
<!ELEMENT head ((title))>
<!ELEMENT h1 ((center))>
<!ELEMENT center ((xsl:value-of))>
<!ELEMENT body ((h1))>
]>
<n1:target xmlns:n1="urn:asdf">
	<xsl:stylesheet id="test" xmlns:n1="urn:asdf" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
		<xsl:output method="html"/>
		<xsl:template match="/">
			<html>
				<head>
					<title>
						<xsl:value-of select="n1:target/n1:title"/>
					</title>
				</head>
				<body>
					<h1>
						<center>
							<xsl:value-of select="n1:target/n1:title"/>
						</center>
					</h1>
				</body>
			</html>
		</xsl:template>
		</xsl:stylesheet>
	<n1:title>This is the title</n1:title>
</n1:target>

tested opera9 firefox4 ie8

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>This is the title</title>
</head>
<body>
<h1>
<center>This is the title</center>
</h1>
</body>
</html>
__________________
Helmut Hagemann Germany

fallen to the bottom of the facts?
I reach my hand and we go together


wer lesen und google kann ist klar im Vorteil
who read and google is able is clear in the advantage

Reply With Quote
  #3  
Old April 17th, 2011, 12:27 PM
_gabe_ _gabe_ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 5 _gabe_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 42 m 12 sec
Reputation Power: 0
Thx Helmut for your reply.

I see the point. But why does everything work quite smoothly if i put the stylesheet in a separate file? So we have the XML and the XSL:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='test02.xsl'?>
<target xmlns="urn:asdf">
  <title>This is the title</title>
</target>


Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:n1="urn:asdf" version="1.0" xmlns:xsl=""> 
  <xsl:output method="html"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:value-of select="n1:target/n1:title"/>
        </title>
      </head>
      <body>
        <h1>
          <center>
            <xsl:value-of select="n1:target/n1:title"/>
          </center>
        </h1>
      </body>
    </html>
  </xsl:template>
  <!--xsl:template match="xsl:stylesheet"/-->
</xsl:stylesheet>


Why is Firefox not able to interpret the style correctly, if its embedded in the XML as shown in my first post? Whereas - if I analyse the generated Code with WebDeveloper it seems to be transformed correctly - only presentation fails.

Thx in advance, _gabe_

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > embedded XSLT????

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap