Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-19-2002, 01:19 AM   PM User | #1
nolachrymose
Regular Coder

 
Join Date: Jun 2002
Posts: 338
Thanks: 0
Thanked 0 Times in 0 Posts
nolachrymose is an unknown quantity at this point
MathML Formatting Problems

Right now I'm learning MathML, and am finding it very confusing. What I have now is a little page that shows the Pythagorean Theorem(sp?). Problem is, it isn't being formatted. I have downloaded the required fonts and it still doesn't work, so I figure it has to do with the code itself. Since I couldn't figure it out myself, I figured I'd ask the experts . Here's the code:

Code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<title>Pythagorean Theorem with MathML</title>
</head>
<body>
	<math xmlns="http://www.w3.org/1998/Math/MathML">
		<mrow>
			<mrow>
				<mi>c</mi>
				<mo>=</mo>
			</mrow>
			<mrow>
				<msqrt>
					<mfenced>
						<mrow>
							<msup>
								<mi>a</mi>
								<mn>2</mn>
							</msup>	
						</mrow>
						<mrow>
							<mo>+</mo>
						</mrow>
						<mrow>
							<msup>
								<mi>b</mi>
								<mn>2</mn>
							</msup>
						</mrow>
					</mfenced>
				</msqrt>
			</mrow>
		</mrow>
	</math>
</body>
</html>
nolachrymose is offline   Reply With Quote
Old 07-19-2002, 01:38 AM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Add a:
<?xml version="1.0"?>

At the top, and save it as .xml.

Remember, HTML does not include XML namespaces - therefore to invoke the XML parser (and in turn MathML parser), you need to give a mime-type of text/xml, application/xhtml+xml, etc (anything that invokes the XML parser).

BTW, all those <mrow>'s aren't necessary:

Code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<title>Pythagorean Theorem with MathML</title>
</head>
<body>
	<math xmlns="http://www.w3.org/1998/Math/MathML">
		<mi> c </mi>
		<mo> = </mo>
		<msqrt>
			<msup>
				<mi> a </mi>
				<mn> 2 </mn>
			</msup>
			<mo> + </mo>
			<msup>
				<mi> b </mi>
				<mn> 2 </mn>
			</msup>
		</msqrt>
	</math>
</body>
</html>
The MathML specs tell viewers to insert them during rendering as necessary.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 07-19-2002, 02:15 AM   PM User | #3
nolachrymose
Regular Coder

 
Join Date: Jun 2002
Posts: 338
Thanks: 0
Thanked 0 Times in 0 Posts
nolachrymose is an unknown quantity at this point
Thanks! Works wonderfully!

Thanks for the notice about <mrow> elements. I was getting lost in them.

Happy coding!
nolachrymose is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:58 AM.


Advertisement
Log in to turn off these ads.