ooops!
This portion:
<xsl:value-of select="foo"/> will output: "this is the value of foo"
<xsl:value-of select="foo"/> will output a copy of all the text elements
as well as the elements and there values that are descendants of foo. o
should have read...
<xsl:value-of select="foo"/> will output: "this is the value of foo"
<xsl:copy-of select="foo"/> will output a copy of all the text elements
as well as the elements and there values that are descendants of foo.
Sorry for the confusion!
<M:D/>
M. David Peterson wrote:
Peter,
I think there are a lot of people on this list that will commend you
for your desire to learn by your own efforts and merits before asking
for the answer. Let me be the first... nice job!
Now... moving forward to help you with solving your dillemma. The
first thing you want to focus on is the difference between what
xsl:value-of will output and what xsl:copy-of will output. Think of
the difference like this... value-of will output the string value of
the current element in context where as copy-of will make a deep copy
of the element and all of its descendants. So, in other words...
given the following XML...
<foo>
this is the value of foo
<bar>this is the value of bar.<p>this is the value of a paragraph
that is the child of bar</p></bar>
</foo>
<xsl:value-of select="foo"/> will output: "this is the value of foo"
<xsl:value-of select="foo"/> will output a copy of all the text
elements as well as the elements and there values that are descendants
of foo. or:
<foo>
this is the value of foo
<bar>this is the value of bar.<p>this is the value of a paragraph
that is the child of bar</p></bar>
</foo>
If you were to use the xsl:copy element you could get selective of
which elements or attributes to include in your copy. So, if I were
you, I would do one of two things... rush out to your local Barnes &
Noble or Borders (or equivalent) and pick up a copy of Dr. Michael
Kays XSLT Developers Reference OR go to the W3C and take a look at the
XSLT 1.0 specification, and focus specifically on the above
elements... learn all about each of them... read the sections over and
over and over again until you finally get it... sometimes this is what
it takes.
If after all this you still are having troubles come back to the list
and showcase the fact that you have done all that you can and you
still are having troubles and I know more than half the people on this
list will be more than happy to help.
Best of luck to you!
<M:D/>
Bradley, Peter wrote:
It pays to be honest, so I'll be up-front about this. The question
arises from an assignment on a course I'm doing.
However, I don't want to cheat, so I'll try to form the question in
the most general way that I can:
The purpose of the exercise is to convert some xml to html. I have a
repeating element under the root - let's call it anElement.
Initially, the requirement was to output all its contents,
unchanged. So I could do this:
<xsl:for-each select="anElement">
<xsl:value-of select="." />
</xsl:for-each>
The anElement element has mixed content and would be described in a
DTD as follows:
<!ELEMENT anElement (#PCDATA | tag1 | tag2 | tag3 | tag4)* >
All the child tags contain #PCDATA only.
The new requirement is to print all the content as before, but to
print the contents of tag2 (say) in italics - i.e. surround its
contents with <i></i> html tags.
I've sweated over this all weekend and can't work out how to solve
it. If I treat each tag individually in a for-each or an
apply-templates/template combination (if that makes sense), I can't
see how to output the #PCDATA in anElement.
Any help would be appreciated - especially a pointer to a resource
that will let me work it out for myself. I've tried the obvious
places like w3c schools.
Thank for your attention
Peter
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--