Re: Adding or modifying by path

Subject: Re: Adding or modifying by path
From: Hans Gerwitz <xml@xxxxxxxxxx>
Date: Wed, 18 Oct 2000 23:53:15 -0500
> I hope I'm not the only one here who has absolutely no idea what
> non-trivial thing you are trying to do. :) What is the input, what is
> the output, what do you mean by /a/b/c and how does that relate to the
> input and output? Where are the 'duplicates' you speak of?

Sorry, in my effort to be concise I apparently went overboard :-)

Input I:
 <a><b><c>42</c></b></a>

Input II:
 <a></a>

Output (from either input):
 <a><b><c>foo</c></b></a>

The "duplicates" I spoke of would be elements, or perhaps more correctly
put, branches of the result tree.

The example above would be accomplished by an XSLT implementing "add a tag
/a/b/c with value 'foo'"  "a/b/c" then is just my XPathish shorthand for an
element and its context.  This shorthand is necessary, as the implementation
will itself be the result of applying a transform to an XML doc that
"defines" a modification such as this.

It is trivial to modify (via a template match) ala Input I or to add a new
element (via xsl:copy and xsl:element) as in Input II.

No amount of contortion, though, has led to a solution that works for both
of the inputs above.  I either fail to create the needed new elements to
input II above, or end up "duplicating" a branch in Input I (e.g. returning
<a> <b><c>42</c></b> <b><c>foo</c></b> </a>)

My attempts thus far have been able to satisfy simple examples (including
this one) but then fail in further testing (e.g. when trying to implement
"add a tag a/b")  I haven't provided sample code because I'm afraid I'd only
further cloud the issue.  Please let me know if anyone would rather debug
:-)

Thanks,
Hans Gerwitz
hans @ phobia . com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread