jasonkarldavis I don't know if XPath respects namespaces when matching attributes and tags or not
jasonkarldavis but the code itself it surprisingly simple
jasonkarldavis I thought it was gonna be way more complicated
WeirdAl well I was primarily concerned about matching by ID
jasonkarldavis but XPath has the nice id() function.... :)
jasonkarldavis which I didn't know about until 3 minutes ago
WeirdAl I figured it'd be simple
WeirdAl I just don't mess with XSLT ;)
jasonkarldavis I figure it is something worth knowing well... so I try to spend time with it now and then to keep fresh
WeirdAl :) -- well, as I said, it's somthing I figured you'd be the one to nail
WeirdAl goes to pull up XPath 1.0
WeirdAl -- I thought you'd use XPointer though
jasonkarldavis XPointer is just like anchors for XML...
jasonkarldavis you can't actually grab content with it
WeirdAl :) I can't exactly tell the diff
jasonkarldavis picture XPointer as a replacement for <a name="myanchor">
jasonkarldavis recommends /XML in a Nutshell/ by O'Reilly
jasonkarldavis best reference I've ever gotten
jasonkarldavis but XML In a Nutshell is *nice*
WeirdAl anyway check out that link I just gave you and tell me if it helps
jasonkarldavis that's not *quite* what I was looking for
WeirdAl try the expanded-names link
jasonkarldavis namespace nodes are one of the things Mozilla's Transformiix doesn't support
WeirdAl section 4.1 of the same doc, what about that?
jasonkarldavis that expanded names thing is what I wanted I think
WeirdAl if Moz supports it...
WeirdAl when in doubt, go get the spec
WeirdAl oh, and can you please make sure that the copy itself doesn't have any id attributes?
WeirdAl -- or better yet, lets me set a new id attribute?
WeirdAl in the original element
WeirdAl for the top element being copied?
WeirdAl -- that would be a killer XSLT app
WeirdAl :) too much to swallow?
jasonkarldavis :: thinking ::
jasonkarldavis <xsl:attribute/> would be beautiful... but copied node isn't the "context node"
jasonkarldavis yeah... I'm trying to think of how to access the copied fragment tree
WeirdAl -- maybe a *second* XSLT stylesheet
WeirdAl -- applied after the first!
jasonkarldavis does XSLT operate on itself? Like, once it figures out how to insert content, does it do it all at once?
jasonkarldavis or does it do it in order?
WeirdAl *shrug* I dunno
jasonkarldavis if it is in order... then you could just find the first-child of //clone
WeirdAl -- but that could be a text node or null
jasonkarldavis well, first element node
jasonkarldavis (and only)
WeirdAl -- would it be guaranteed to be the intended node?
jasonkarldavis you can't select document fragments until XPointer works... therefore you are guarenteed that the <xsl:copy-of select="blabla"/> is an element node
jasonkarldavis besides, id() in this case only can return a single element node
WeirdAl -- in theory
jasonkarldavis as only elements can have id's
WeirdAl ah, but then we run into docs with two elems sharing the same id
jasonkarldavis which are invalid HTML/XHTML, but still well-formed XML....
jasonkarldavis id() can take multiple arguments
jasonkarldavis and will return a node-set of all matching nodes
WeirdAl -- hence why I'm trying to make sure we keep cloned id's out
jasonkarldavis or if multiple elements have the same id(), it returns a node-et of them
WeirdAl XSLT 1.0, Section 5.7: Modes allow an element to be processed multiple times, each time producing a different result.
jasonkarldavis does this reprocessing also pick up on previously inserted XSLT-generated templates?
WeirdAl read it
WeirdAl seems to
jasonkarldavis well then, create another template after this one
WeirdAl not me :)
jasonkarldavis is this my project now? ;) :D
WeirdAl -- I'm trying to figure out if XSLT lets us remove things instead of just creating them
jasonkarldavis I can "reset" the id attribute
WeirdAl :) that'd be cool -- if you reset them all to "" for the copy
jasonkarldavis <xsl:template match="//clone/*[position() = 1]">
jasonkarldavis <xsl:attribute name="id"/>
jasonkarldavis the content of <attribute/> is the new attribute value
jasonkarldavis in this case, I don't put anything in
jasonkarldavis ? :)
WeirdAl that makes life interesting -- especially if you use a conditional to determine if it's the element actually being cloned
WeirdAl -- I think
jasonkarldavis well, we are assuming that the only children of <clone/> are what we put there via XSLT
jasonkarldavis which we become sure of it just a single element
WeirdAl which for the moment they would be
jasonkarldavis unless we have multiple same id;'s
WeirdAl uh oh... :)
jasonkarldavis which probably implies we are inserting content at a sibling level as a child of <clone/>?
WeirdAl hm -- yeah, that would be the safe bet
jasonkarldavis instead of only having firstChild, we have childNodes
WeirdAl oh, wait
jasonkarldavis which then makes:
jasonkarldavis match="//clone/*[position() = 1]"
WeirdAl -- what I don't get is why we can't just replace <jsl:clone />
jasonkarldavis simply replace the node?
WeirdAl that's safer imho
jasonkarldavis it would be easier to keep everything as children of it
jasonkarldavis plus, this way is more in line with the SVG spec
jasonkarldavis which you mentioned
WeirdAl -- does use create childnodes?
jasonkarldavis <use/> basically inserts almost anonymous content
jasonkarldavis the DOM only sees <use/>, but you can access its content through a property
WeirdAl heh, I'm rusty on the SVG DOM :)
jasonkarldavis UseElement.hasChildNodes() should be false