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 March 30th, 2004, 05:09 PM
adorablepuppy's Avatar
adorablepuppy adorablepuppy is offline
Come to the door. . .
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: Ohio
Posts: 813 adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 13 h 9 m 26 sec
Reputation Power: 142
Send a message via MSN to adorablepuppy Send a message via Google Talk to adorablepuppy
Question XSL code won't format <child/> node

The XSL I have made is based mainly on div tags with style attributes. Here's the XML document. It won't render "Links" under <SIDE></SIDE>.The gibberish in the <POST></POST> tag is to test the word-wrapping.
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Underscore.xsl"?>
<PAGE>
<TOP>Underscore</TOP>
<SIDE><a href="http://www.geocities.com">Links</a></SIDE>
<POST>OOPGRJEGHJKLJIWSIFDPSIOGGGGGGIKKKKKKKKFFFFFFFGGGGGROEJGGFLSJGLKFDJSKLJFLDSJLFJDLSJGRIOVJFSPOIFODSKGO  RRRRSGFSHJKGHREKVJNDFSLUTIRISLNGILRMSINGSFLDNFIIIIDUSIGNURIOWSGPROSPUGIERUIOPWSNGUIEUSIUGIDSNJFIWSJD  HSSOGNRUOSIUUGGUIEORDSOYUEWUOQQORIUSUAIFUYHEHWUSHVF</POST>
</PAGE>

Here's the XSL stylesheet.
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="br">
	<br/>
	<xsl:apply-templates/>
	</xsl:template>
<xsl:template match="PAGE">
<html>
<body style="margin:0px;">
<children/>
</body>
<xsl:apply-templates/>
</html>
</xsl:template>

	<xsl:template match="SIDE">
	<div style="background-color:00BBFF;width:20%;height:100%;float:right"><div style="margin-top:10px;font-size:30px"><child/></div></div>
	<xsl:apply-templates/>
	</xsl:template>

<xsl:template match="POST">
<div style="margin-left:10px;margin-right:10px;word-wrap:break-word">
<P>
<children/><xsl:apply-templates/>
</P>
</div>
</xsl:template>

	<xsl:template match="TOP">
	<div style="background-color:00BBFF;width:100%;height:20%;text-align:center;font-size:60px;font-family:anythingyouwant;color:0066BB">
	<div style="margin-top:10px"><children/></div>
	<xsl:apply-templates/>
	</div>
	</xsl:template>	

</xsl:stylesheet>

Any help will be appreciated.
Thanks.

Reply With Quote
  #2  
Old March 31st, 2004, 02:06 PM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 259 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 23 h 16 m 51 sec
Reputation Power: 6
Try the following (I removed the styling code for clarify):

Code:
	

      <xsl:template match="SIDE">
	<xsl:copy-of select="./a"/>
      </xsl:template>

Reply With Quote
  #3  
Old April 1st, 2004, 11:47 AM
adorablepuppy's Avatar
adorablepuppy adorablepuppy is offline
Come to the door. . .
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: Ohio
Posts: 813 adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 13 h 9 m 26 sec
Reputation Power: 142
Send a message via MSN to adorablepuppy Send a message via Google Talk to adorablepuppy
That code didn't work? Not for me at least. When I did that, it made Links copy, turn blue and hyperlink to geocities.com.... Wonder what i'm doing wrong.

Reply With Quote
  #4  
Old April 1st, 2004, 03:15 PM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
Quote:
That code didn't work? Not for me at least. When I did that, it made Links copy, turn blue and hyperlink to geocities.com.... Wonder what i'm doing wrong.


I am confused ... isn't this what you want it to do? What do you mean by "It won't render links under <SIDE></SIDE>?"

Reply With Quote
  #5  
Old April 1st, 2004, 03:26 PM
tsprings tsprings is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Seattle, WA
Posts: 55 tsprings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 5
Hi AdorablePuppy.

I suggest you take a look at W3 Schools for more info on xsl.

I reformatted your whole XSL document (using the code posted by fpmurphy), which included links to the right (right where you specified in the style for that div). This does link to google, because that's what address you had specified in your xml doc.

Links was showing up an extra time because of some incorrect xsl, but that should be cleaned up now and closer to what you are looking for.

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
      <body style="margin:0px;">
            <xsl:apply-templates/>
      </body>
</html>
</xsl:template>

<xsl:template match="SIDE">
       <div style="background-color:00BBFF;width:20%;height:100%;float:right">
            <div style="margin-top:10px;font-size:30px">
                 <xsl:copy-of select="./a"/>
            </div>
       </div>
</xsl:template>

<xsl:template match="POST">
        <div style="margin-left:10px;margin-right:10px;word-wrap:break-word">
             <P><xsl:apply-templates/></P>
        </div>
</xsl:template>

<xsl:template match="TOP">
	       <div style="background-color:00BBFF;width:100%;height:20%;text-align:center;font-size:60px;font-family:anythingyouwant;color:0066BB">
	            <div style="margin-top:10px"></div>
	                 <xsl:apply-templates/>
	       </div>
</xsl:template>	
</xsl:stylesheet>

Reply With Quote
  #6  
Old April 1st, 2004, 04:41 PM
adorablepuppy's Avatar
adorablepuppy adorablepuppy is offline
Come to the door. . .
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: Ohio
Posts: 813 adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 13 h 9 m 26 sec
Reputation Power: 142
Send a message via MSN to adorablepuppy Send a message via Google Talk to adorablepuppy
Well....

Could you show me what was incorrect? I want to learn from this experience.
I've read through the W3's XML and XSL specifications.
I've referenced several XSL documents...
I've read through the latest edition of the XML Handbook.
But none of these things acutally HELPED me with XSL because I didn't understand how it worked by reading it. I have to understand it through experiencing my problems... That's why I need to learn from my mistake by you posting the incorrect XSL.
Thank you...

Last edited by adorablepuppy : April 1st, 2004 at 04:48 PM.

Reply With Quote
  #7  
Old April 1st, 2004, 05:58 PM
tsprings tsprings is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Seattle, WA
Posts: 55 tsprings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 5
Quote:
Originally Posted by adorablepuppy
I've read through the W3's XML and XSL specifications.
I've referenced several XSL documents...
I've read through the latest edition of the XML Handbook.
But none of these things acutally HELPED me with XSL because I didn't understand how it worked by reading it.

That is why I recommended that you look up W3 Schools, because W3 Schools is very clear and easy to understand... A great resource for learning XSL. I am a kinesthetic learner as well, and W3 Schools provides some great examples.

Quote:
Originally Posted by adorablepuppy
I have to understand it through experiencing my problems... That's why I need to learn from my mistake by you posting the incorrect XSL.
Thank you...

I'm not sure what you mean by me posting the incorrect XSL, as you can compare an contrast your XSL and the XSL I provided and see where they differ... Nonetheless, I have included another XSL that is well commented and includes your code that I changed, as well as explanations as to why I changed what I did.

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!--Why are you making a separate template that inserts a <br />?  Why not just insert it where
        you need it in your XSL?  I would strongly suggest removing this.  
	<xsl:template match="br">
	<br/>
	<xsl:apply-templates/>
	</xsl:template>-->
  
  <!--Ok, so here you're matching your root element.  That's fine.  For ease
       of use, I'd put my rood-matching template first thing in the xsl file.-->
  <xsl:template match="PAGE">
  <html>
        <!--So you declare the body tags for the html, that is fine, but then
              you declare 'children'.  I'm not exactly sure what you are trying 
              to accomplish with this, and I'd remove it.  I'd also place the 
              xsl:apply-templates inside the body tags.
              <body style="margin:0px;">
                    <children/>
              </body>
              <xsl:apply-templates/>-->
          <body style="margin:0px;">
                    <xsl:apply-templates/>  <!-- Here we apply templates so, all the other
                                                              templates in our document should automatically
                                                              be called by this - no need to keep calling in other
                                                              template definitions. -->
          </body>               
  </html>
  </xsl:template>

  <!-- Again, I don't know what you're trying to accomplish with the <child/> tag... You can
        use <xsl:value-of select="."/> to select the text value of element a.   If you are wanting 
        to select the value of the attribute href, we could use <xsl:value-of select="a/@href"/> 
        to pick up that info.  Really, what fpmurphy posted is probably the easiest way to get this
        data, though you could replace it with something like this:
                     <a href="{a/@href}"><xsl:value-of select="."/></a>
        -->
	<xsl:template match="SIDE">
	       <div style="background-color:00BBFF;width:20%;height:100%;float:right">
               <div style="margin-top:10px;font-size:30px">
                    <xsl:copy-of select="./a"/> <!-- A <xsl:copy-of select="."/> could also be used, 
                                                                  but specifiying the a element is a way of making
                                                                  sure that only the a element information is 
                                                                  selected. -->
               </div>
         </div>
	<!-- Why are you trying to apply templates again?  From what I can see, you don't need to...         
         <xsl:apply-templates/>
          -->  
	</xsl:template>

  <!-- Here we go again with a <children/> tag... Take that out, and then replace apply-templates
         with <xsl:value-of select="."/> which will select all the text of the POST element.-->
  <xsl:template match="POST">
        <div style="margin-left:10px;margin-right:10px;word-wrap:break-word">
               <P>
                     <!--<children/><xsl:apply-templates/>-->
                      <xsl:value-of select="."/>
               </P>
          </div>
   </xsl:template>

   <!-- Ok, almost done!  Once again, clean up your code by removing the <children/> tag, then 
         take out that xsl:apply-templates, and actually select the value of TOP. -->
	<xsl:template match="TOP">
	        <div style="background-color:00BBFF;width:100%;height:20%;text-align:center;font-size:60px;font-family:anythingyouwant;color:0066BB">
	             <div style="margin-top:10px">
                    <xsl:value-of select="."/>
               </div>
	             <!--<xsl:apply-templates/>-->
	         </div>
	</xsl:template>	
</xsl:stylesheet>

<!-- Finally, just a closing thought, why don't you link to a CSS that does your formatting instead 
      of having those huge bits of style right in your code?  Another matter of preference, but it
      would definately clean up your code even more.  :-)  -->


Let me know if you have further questions.

Reply With Quote
  #8  
Old April 2nd, 2004, 07:54 AM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 259 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 23 h 16 m 51 sec
Reputation Power: 6
>>I've read through the W3's XML and XSL specifications.

W3C recommendations and other standards documents
are written in a terse style - typically referred to as
standardese - and are unintelligible to most people
trying to learn a language or programming paradigm. You
should do a Web search for XSLT tutorials and work
you way through as many of these as possible or sign
up for a course on XML/XSLT.

Reply With Quote
  #9  
Old April 2nd, 2004, 12:10 PM
adorablepuppy's Avatar
adorablepuppy adorablepuppy is offline
Come to the door. . .
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: Ohio
Posts: 813 adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 13 h 9 m 26 sec
Reputation Power: 142
Send a message via MSN to adorablepuppy Send a message via Google Talk to adorablepuppy
Well.. Thank you guys. You've helped me better myself as a web designer.
One thing i've been wondering about...
The CSS "height" and "width" styles.... Is there any actual way to get them actually 100% down the page? When you put "height:100%;" It does in fact go 100% of A single page. If anything in any other division extends beyond that... The previous division that has the 100% width or height stops beyond the first part of the page.

Reply With Quote
  #10  
Old April 6th, 2004, 12:47 PM
adorablepuppy's Avatar
adorablepuppy adorablepuppy is offline
Come to the door. . .
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: Ohio
Posts: 813 adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level)adorablepuppy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 13 h 9 m 26 sec
Reputation Power: 142
Send a message via MSN to adorablepuppy Send a message via Google Talk to adorablepuppy
By the way... I DID put that piece of code that places a line break in for a reason. Sometimes when i'm writing a paper or something, I like to line break for no reason, and I see no need for having to do this:
Code:
<POST> . . . </POST>
<POST> . . . </POST>
if I can just go:
Code:
<POST> . . . <br/><br/> . . . </POST>
. Get it? The first would adds three extra keystrokes... and nobody wants to do more work than they should have to! ... lol j/k.
And sometimes I just randomly

press the enter
key.
I like

that.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL code won't format <child/> node


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 |