|
This page should be used for posting questions, responses and
comments related to XML. Comments posted using the box at the bottom of
the page will be appended to the page. Text can be inserted or edited
anywhere on the page using the Edit link. To post XML code examples: put two colons in a row
at the end of the text above the XML and then indent each line of XML one space.
... -- Sat, 15 Jan 2005 14:15:43 -0500 reply
Hello,
This does not look good. I typed using my editor the following text:
-----------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World again</h1>
</body>
</html>
-----------------------------------------------------------------
part of the sample code from the class. I am off line. I saved the file. After opening the file with FireFox? I am getting:
"This XML file does not appear to have any style information associated with it. The document tree is shown below."
I tried to find something on the WEB - so far no cigar. I am hoping this is goin got be faster.
Help please,
Pedro
Piotr Drzewinski
pitord@yahoo.com
... -- Sat, 15 Jan 2005 14:19:19 -0500 reply
Hello again,
The code executes nicely on this page, on mine I get the error and code itself.
Pedro
Piotr Drzewinski
pitord@yahoo.com
... -- Mon, 17 Jan 2005 18:55:39 -0500 reply
Hello yet again,
It seems to me like I am talking to myself, but so what... Thanks to the help of my fellow student Mr. Al-Droubi I discovered that the above described erroneous behavior occurs when the source file extension is .xml, with an .html extension the browser works fine. So the question is, how do we make the browser interpret the *.xml files correctly.
Thank you in advance,
Piotr Drzewinski
"Erroneus behavior" --harrison, Tue, 18 Jan 2005 12:56:48 -0500 reply
Actually, you're not getting an error. XML files don't have an intrinsic display format. How would a browser know how text should be displayed when you are free to invent your own tags? The answer is that XML files are set up for display using stylesheets, which we'll hear about in a couple of weeks. If a stylesheet is specified, Firefox will display the XML document according to the defined styles; if no stylesheet is specified, Firefox shows the XML document structure as a collapsible document tree or outline, which is correct behavior. Since XHTML is basically HTML that is compliant with XML rules, if you want a browser to use the default HTML styles to display the XHTML, just use the .html filename extension as you mention above. -- JHH
Posting code --harrison, Tue, 18 Jan 2005 12:58:58 -0500 reply
If you want to post HTML or XML code to these pages, just put two colons in a row at the end of the line above the code and then indent each line of code one space. When you're done with the code part, just stop indenting. Only one of the colons will be shown and the server will interpret all the indented lines as text that should be shown exactly as is. The first comment above demonstrates this. -- JHH
cant load in morphon -- Mon, 24 Jan 2005 12:24:32 -0500 reply
I have made demo XML and DTD documents based on the text document assigned for HW ...but while trying to load in morphon; these documents dont load and I get an error " cant load document; missing byte order mark..."
Also when i try to validate these documets using the validate option in morphon i get the error : "no more psedu attributes allowed"
and it is in the column 54 of the line below:
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
Any suggestions anyone????????
Kanishka Bhutani
Loading into Morphon -- Thu, 27 Jan 2005 09:24:34 -0500 reply
This line doesn't give me a problem when I put it at the top of a generic XML document in Morphon. I wonder whether there is some code in your file that is not legal for XML, or whether the file might not be UTF-16. What program did you use to make the file? Are you sure it's output is UTF-16? If you just take the defaults (for example, <?xml version="1.0">), does that work OK? -- JH
XML Editors -- Fri, 04 Feb 2005 08:42:52 -0500 reply
I downloaded and evaluated a few XML editors and I didn't think they are that much better than a good general Programmer's editor such as Visual Slickedit or Emacs. I was wondering what the other students felt about this.
xpath and xslt -- Thu, 24 Feb 2005 16:33:06 -0500 reply
It seems to me that there is some inconsistancy of how xpath works in xsl. Using the CD catalog example from http://www.w3schools.com/xpath/xpath_intro.asp, the expression /CATALOG/CD selects all the CD elements of the catalog element (I tried it in morphon). However, in an xslt document /CATALOG/CD will only return the first element. To iterate over all CD elements one would have to use xsl:for-each. Am I correct here?
re: xpath --harrison, Thu, 24 Feb 2005 17:06:52 -0500 reply
Take a look at this reference on displaying multiple items of the same type: http://www.dpawson.co.uk/xsl/sect2/N3235.html#d3863e238
You do select all the CD elements, but your template may tell the processor to just process through one of them. This is subtle and it may help to think of it in terms of what the processor is seeing. If you select all the CD elements and start processing, you hit the first CD element and do your initial stuff, then you process on through (perhaps with an apply-templates) and when you hit the close tag for the first CD, your template stops. There's nothing to tell it to do anything with the remaining CD elements. You could deal with this using xsl:for-each, which tells the processor to do the same thing to each CD element (you couldn't do this unless you already had selected all of them, right? For-each doesn't select, it processes what you have already selected). Or, you could select /CATALOG and put inside its template an xsl:apply-templates. Then make a separate tempate for CD. If you do that, you'll see that it will get applied to each CD element. The key is that the processor moves through the text sequentially. It has no concept of selecting a whole bunch of stuff and doing things to it all at once. -JH
re:re: xpath -- Thu, 24 Feb 2005 20:55:53 -0500 reply
Dr. Harrison,
Now that you explained, it makes more sense to me. The difference is subtle and I guess in a way it works like SQL, you open a cursor and then fetch through each record one at a time with a for statement. I think the xsl:apply-templates is a very neat operator as it allows one to write recursive code, a little twisted but neat. -S. Al-Droubi
XSLT Problem -- Mon, 04 Apr 2005 17:05:49 -0400 reply
In my xslt document I have the following code which is supposed to generate an html link.
It actually does the transformation to what I expect "in text" but Firefox does not show it as a link. Any idea why Firefox is behaving this why?:
<xsl:if test="count(./dic_item_def/link_syn)>0">
<b>Synonym:</b>
<xsl:for-each select="./dic_item_def/link_syn">
<a href="<xsl:value-of select="location"/>">
<xsl:value-of select="loc_text"/>
</a>
</xsl:for-each>
<xsl:value-of select="./dic_item_def/item_def"/>
<br/>
</xsl:if>
Generated xhtml below:
Synonym: <a href="contact_dermatitis.htm"> Contact dermatitis </a>
--Sam Al-Droubi
re: XSLT --harrison, Mon, 04 Apr 2005 17:21:38 -0400 reply
This is a bit challenging, because you're trying to use xsl tags to insert values for attributes inside xml tags (if I understand correctly what you're trying to do). This, of course, creates illegal xml in the template unless you do something about it. Using entities like you did will make the transformation template legal xml, but you'll get out something that will display the character sequence of an xml tag inside a browser rather than understand it as a tag. Thus, no link. This problem is addressed in the Nutshell book in the chapter on XSLT. Look at the section called "Attribute Value Templates." You should be doing something like this:
<xsl:if test="count(./dic_item_def/link_syn)>0">
<b>Synonym:</b>
<xsl:for-each select="./dic_item_def/link_syn">
<a href="{location}"><xsl:value-of select="loc_text"/></a>
</xsl:for-each>
<xsl:value-of select="./dic_item_def/item_def"/>
<br/>
</xsl:if>
Notice the XPath expression in curly brackets, {location}. Assuming you're in a context (a document location) where there is a child tag named location, this will get the value of that and insert it in place of itself. You can use any XPath expression in the curly braces and it will be evaluated and replaced with the result.
re:re: XSLT -- Mon, 04 Apr 2005 23:06:03 -0400 reply
Thank you. Your suggestion fixed it.
How to get rid of whitespace- xml to xhtml using xslt ? -- Sun, 10 Apr 2005 12:27:26 -0400 reply
I want to remove the leading and trailing whitespace for certain elements when transforming from xml to xhtml using xslt. Does anyone know how to do this? I am struggling in figuring this out! Can someone help me? --Sam Al-Droubi
re:Whitespace Stripping : The normalize-space( ) function and
xsl:strip-space element -- Tue, 12 Apr 2005 12:59:09 -0400 reply
String normalize-space( )
String normalize-space(string s )
The normalize-space( ) function strips all leading and trailing whitespace from its argument and replaces each run of whitespae with a single space character. Among other effects, this removes all line breaks…(Nutshell book, chapter: XSLT Reference).
xsl:strip-space elements=”QualifiedName_1 QualifiedName?_2…”
The top-level xsl:strip-space element specifies which elements in the source document have whitespace stripped from them before they are transformed. Whitespace stripping removes all text nodes that contains only whitespace…(Nutshell book, chapter: XSLT Reference). -François
|