[thelist] xsl-Expected token 'eof'

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Wed Jan 15 08:07:00 CST 2003


> The @ character needs to be preceeded by a / to denote that the id is an
> attribute of the message, so:
>
> >      <xsl:value-of select="message at id"/>
>
> becomes:
>
> <xsl:value-of select="message/@id" />
>
> You'll need to change this for every time you're trying to use an
attribute
> in your XSL document.

Since this can trip a lot of people up when they are dealing with XML, I
would just like to add for clarification that when you are referencing your
attributes (or even text data) remember that you are still referencing a
node, just like any other node. In other words, given this XML document:

<people>
	<person id="1">
		<name>John Doe</name>
		<age>26</age>
	</person>
	<person id="2">
		<name>Jane Doe</name>
		<age>42</age>
	</person>
</people>

Then the resulting internal XML object tree looks roughly like this:

::DOCUMENT_ELEMENT::  (super-root node, inaccessible)
|-/ people {type:element}
      |-/ person {type:element}
            |-/ id {type:attribute}
                  |-/ PCDATA {type:text} (contains the text "1")
            |-/ name {type:element}
                  |-/ PCDATA {type:text} (contains the text "John Doe")
            |-/ age {type:element}
                  |-/ PCDATA {type:text} (contains the text "26")
      |-/ person {type:element}
            |-/ id {type:attribute}
                  |-/ PCDATA {type:text} (contains the text "2")
            |-/ name {type:element}
                  |-/ PCDATA {type:text} (contains the text "Jane Doe")
            |-/ age {type:element}
                  |-/ PCDATA {type:text} (contains the text "42")

I haven't seen many resources that really explain this to developers.

HTH,
-dave



More information about the thelist mailing list