Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you find my error? 1

Status
Not open for further replies.

kingspade350

Technical User
Aug 23, 2011
8
US
<?xml version = "1.0"?>

<notes>
<unit1>
<chapter1>
<roman_numerals>
<I>"Discovering America"
<Capital_letters>
<A>Scandinavian Ventures
<numbers>
<1>Norse seafares</1>
<2>Vikings (grapes)</2>
<3>New foundland Area</3>
</numbers>
</A>
<B>European Desires
<numbers>
<1>Contact + success with Asian Conquests</1>
<2>Physical Rewards(Drugs, Silk, perfumes, + spices)</2>
<3>Medieval Crusades (1095)(Compass, maps, Astrolabs)</3>
<4>Marco Polo(1295)</4>
<5>Asian Trade Priblems
<small_letters>
<a>Sea routes = slow ships</a>
<b>Land routes = slow + dangerous</b>
</small_letters>
</5>
</numbers>
</B>
<C>Africa
<numbers>
<1>North Africa had been known since antiquity</1>
<2>Subsaharan Africa began to be explored by the portuguese</2>
<3>Mali Kingdom -> Gold * <fo:inline text-decoration="underline">Slaves</fo:inline></3>
<4>*Bartholemeau Dias (1488)</4>
</numbers>
</C>
</Capital_letters>
</I>
</roman_numerals>
</chapter1>
</unit1>
</notes>
 
as of right now this isn't an elaborate program, but im just making it then i will style it later. But when i run it it tells me i have a parse error on line 10 or <1>Norse Seafares</1>. I can't find it and have tried everything
 
Try searching for xml element naming rules

Tom Morrison
Micro Focus
 
Thanks man i understand now, so basically i can't start a tag with a number, right? Thats what i read, now after I edit this i can repost if necessary(if i can't get it to work)?
 
ok so now i have my xml setup and better understand that. My new problem is styling it. Heres my xml code
Code:
<?xml version = "1.0"?>
<?xml-stylesheet type="text/xsl" href="Ap project xsl.xsl"?>

<notes>
	<unit1>	
		<chapter1>	
				<roman_numerals>
					<I>"Discovering America"</I>								
						<A>"Scandinavian Ventures"</A>
							<numbers>
								<N.1>Norse seafares</N.1>
								<N.2>Vikings (grapes)</N.2>
								<N.3>New foundland Area</N.3>
							</numbers>												
						<B>European Desires</B>													
							<numbers>
								<N.1>Contact + success with Asian Conquests</N.1>
								<N.2>Physical Rewards(Drugs, Silk, perfumes, + spices)</N.2>
								<N.3>Medieval Crusades (1095)(Compass, maps, Astrolabs)</N.3>
								<N.4>Marco Polo(1295)</N.4>
								<N.5>Asian Trade Priblems
									<small_letters>
										<a>Sea routes = slow ships</a>
										<b>Land routes = slow + dangerous</b>
									</small_letters>
								</N.5>
							</numbers>						
						<C>Africa</C>
							<numbers> 
								<N.1>North Africa had been known since antiquity</N.1>
								<N.2>Subsaharan Africa began to be explored by the portuguese</N.2>
								<N.3>Mali Kingdom -> Gold * <underline>Slaves</underline></N.3>
								<N.4>*Bartholemeau Dias (1488)</N.4>
							</numbers>						
				</roman_numerals>
		</chapter1>		
	</unit1>
</notes>

Here is my xsl code.
Code:
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match = "/notes">
<html>
<body>
<style type = "text/css">
	body 
	{
	background-image:url('bgimg.jpg');
	background-position:top left;
	font-size: 25px;
	font-family:"Times New Roman", Times, serif;
	}
	
	Span.indent1
	{
	text-indent:5px;
	}
	
	Span.indent2
	{
	text-indent:30px;
	}
	
	Span.indent3
	{
	text-indent:55px;
	}
	
	Span.indent4
	{
	text-indent:80px;
	}
	  
</style>
<h2> Welcome to My website. This is an AP US History help site. </h2>
	<xsl:for-each select = "unit1/chapter1/roman_numerals" >
	<span class = "indent1">
	<p>I.<xsl:value-of  select = "I" /><br /></p>
	</span>
	
	<span class = "indent2">
	<p>A)<xsl:value-of select = "A" /><br /></p>
		<xsl:for-each select = "numbers">
			<span class = "indent3">
			<p>1.<xsl:value-of select = "N.1" /><br /></p>
			<p>2.<xsl:value-of select = "N.2" /><br /></p>
			<p>3.<xsl:value-of select = "N.3" /><br /></p>	
			</span>
		
		
	<p>B)<xsl:value-of select = "B" /><br /></p>
			<span class = "indent3">
			<p>1.<xsl:value-of select = "N.1" /><br /></p>
			<p>2.<xsl:value-of select = "N.2" /><br /></p>
			<p>3.<xsl:value-of select = "N.3" /><br /></p>
			<p>4.<xsl:value-of select = "N.4" /><br /></p>
			<p>5.<xsl:value-of select = "N.5" /><br /></p>
				<span class = "indent4">
				<p>a.)<xsl:value-of select = "a" /><br /></p>
				<p>b.)<xsl:value-of select = "a" /><br /></p>
				</span>
			</span>	
			
	<p>C)<xsl:value-of select = "C" /><br /></p>	
			<span class = "indent3">
			<p>1.<xsl:value-of select = "N.1" /><br /></p>
			<p>2.<xsl:value-of select = "N.2" /><br /></p>
			<p>3.<xsl:value-of select = "N.3" /><br /></p>	
			</span>
		</xsl:for-each>
	</span>
	</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks for the help. Truthfully i'm a newbie at xml and thought it would be the best method for all my data that i had to input(if there is a better way please tell me). Btw i want to make my project to post my notes in my Ap us class. Thanks again
 
You have made the classic mistake of combining content with presentation. Until you cure this, your efforts with XSL will be painful and ultimately fruitless.

Go back to your XML document. The content for a unit might well be contained in a <unit>...</unit> tag pair, because it is a unit. It is not a <unit1>. If it is the first unit, that is an attribute of a <unit>, which very well might be expressed in XML as <unit unitNumber="1">...</unit>. Rinse and repeat for such things as <chapter>, <heading>, <subheading>, etc.

If this is an XML expression of an outline, then you can nest levels in the following manner:
Code:
<unit>
   <chapter>
      <level>
         <level>
         </level>
      </level>
   </chapter>
</unit>

If you structure your XML correctly, for example, you can use different XSL stylesheets to create (1) an outline using only heading information and (2) a handout with all the material pleasantly formatted.

Tek-Tips is not a place to seek tutorial information, though. I would suggest W3Schools as a decent starting tutorial. Focus on the concepts presented, especially on the remarks about differences between XML and HTML. (You tried to HTML-ize your XML document.) I am not redirecting you away from Tek-Tips in the sense of banishment (I certainly don't have that authority if that were my purpose), but rather to suggest a site better designed for learning. I rather admire your willingness to learn a technology outside your profession (assuming that is what you are doing).

Tom Morrison
Micro Focus
 
Thank you. I understand now or at least have a better grasp of what i should do. And thank you, i love learning these types of languages and my profession will ultimately benefit from my learning. My profession is computer programing, but if i learn how to apply in any situation that i can will ultimately make me a better programmer. I will continue to try and as i progress i will keep posting if i have further trouble.
 
Also question, i create tags because they are needed to display specific information like:
<I><I_S>"Discovering America"</I_S>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</I>

I need to display Discovering America but without displaying all the other info. Is there a way to do that more efficiently than the way I'm doing it.
 
As you are designing an XML document, you should use the XML structure to answer the 'what' question, almost without regard to the 'how will it look' question.

If you need to separate information because it is something different, such as a title or one sentence description of additional information, then that is the reasonable thing to do.

With that said, if I read your question correctly, yes, that seems to be a reasonable way to separate a title from other related content.

Tom Morrison
Micro Focus
 
thank you man, ok i was worried that i was making it way too hard for this. So i thank you. I also want to thank you for this website, i know i might be a beginner and your thinking OMG shut up and go play with html, but this site is really helpful.
 
ok 1 question how do i delete a post i have typed, if there isn't a way, then i believe there needs to be one. Btw here is my code that i have redone tell me if this is more xml rather than HTML'd xml :)

Code:
<?xml version = "1.0"?>
<?xml-stylesheet type="text/xsl" href="Ap styler.xsl"?>

<notes>
	<unit>	
		<chapter title = "Chapter 1">
						<roman_numeral rn = "I">				
						<title>"Discovering America"</title>						
					<capital_letter bletter = "A">
								<title>"Scandinavian Ventures"</title>
						<number bullet = "1.">
								<info>Norse seafares</info>
						</number>
						<number bullet = "2.">
								<info>Vikings (grapes)</info>
						</number>
						<number bullet = "3.">
								<info>New foundland Area</info>
						</number>
					</capital_letter>
					<capital_letter bletter = "B">
						<number bullet = "1.">
								<info>Contact + success with Asian Conquests</info>
						</number>
						<number bullet = "2.">
								<info>Physical Rewards(Drugs, Silk, perfumes, + spices)</info>
						</number>
						<number bullet = "3.">
								<info>Medieval Crusades (1095)(Compass, maps, Astrolabs)</info>
						</number>
						<number bullet = "4.">
								<info>Marco Polo(1295)</info>
						</number>
						<number bullet = "5.">
								<info>Asian Trade Priblems</info>
							<small_letter sletter = "a.)">
								<footnotes>Sea routes = slow ships</footnotes>
							</small_letter>
							<small_letter sletter = "b.)">
								<footnotes>Land routes = slow + dangerous</footnotes>
							</small_letter>
						</number>
					</capital_letter>
					<capital_letter bletter = "C">
						<number bullet = "1.">
						
						</number>
					</capital_letter>
				</roman_numeral>
		</chapter>		
	</unit>
</notes>

still working on getting all my data in then i will work on my xslt. :|
 
Not really...

Looking at this;
Code:
        <chapter title = "Chapter 1">
                        <roman_numeral rn = "I">                
                        <title>"Discovering America"</title>                        
                    <capital_letter bletter = "A">
                                <title>"Scandinavian Ventures"</title>
                        <number bullet = "1.">
Your use of <roman_numeral> and <capital_letter> etc are an indication that you are still trying to put information about how the content should look (that is, presentation) into the actual content.

Ask yourself this: How many things would I have to 'fix' if I needed to insert a new <capital_letter> between my current A and B? You will have separated content from presentation when you can answer the question with, "Nothing else, just add the new content." Right now, you would have to go adjust the exist B to be a C, the existing C to be a D, etc. Can you imagine imposing this burden on any but the most trivial document?

Another way to think about it: What if I were told that I had to switch from Roman numerals, capital letters, etc, to a more modern dotted notation, e.g 2.3.1 instead of II C i? When you have the XML correct, you will be able to do this simply by changing the XSLT style sheet. Your XSLT will have to infer presentation fromthe structure of the XML document.

Tom Morrison
Micro Focus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top