Hey,
I'm trying to have Builder help me turn some YAML into XSLT that does
search and replace. I've gotten most of it down (and working a helluva
lot faster than YAML->XML->XSLT->XSLT...) but am struggling with a
couple of issues. Everybody will probably tell me to use a different
XML writer, and that's ok, I guess...
The documentation says I can declare a namespace like this:
xml.SOAP :Envelope
How do I combine that with attributes? I'd like to do this, but it
doesn't work:
xml.xsl :variable ("name"=>"cats") # and this in different orders
Nor does:
xml.tag!("xsl:variable" "name"=>"cats") # and this with different
grouping
Also, is there any way to make elements with a '-' in the name, as in
<apply-templates/>?
This doesn't work:
xml.apply-templates
In summary, is there a way to make this?
<xsl:stylesheet version="1.0">
<xsl:apply-templates select="cats"/>
...
</xsl:stylesheet>
Many thanks,
Keith
Keith Fahlgren <keith@oreilly.com> writes:
Hey,
I'm trying to have Builder help me turn some YAML into XSLT that does
search and replace. I've gotten most of it down (and working a helluva
lot faster than YAML->XML->XSLT->XSLT...) but am struggling with a
couple of issues. Everybody will probably tell me to use a different
XML writer, and that's ok, I guess...
Following code is untested, and just from the source:
The documentation says I can declare a namespace like this:
xml.SOAP :Envelope
How do I combine that with attributes? I'd like to do this, but it
doesn't work:
xml.xsl :variable ("name"=>"cats") # and this in different orders
Nor does:
xml.tag!("xsl:variable" "name"=>"cats") # and this with different
grouping
Did you try xml.xsl :variable, "name" => "cats" ?
Also, is there any way to make elements with a '-' in the name, as in
<apply-templates/>?
This doesn't work:
xml.apply-templates
xml.tag! "apply-templates"
In summary, is there a way to make this?
<xsl:stylesheet version="1.0">
<xsl:apply-templates select="cats"/>
...
</xsl:stylesheet>
xml.xsl :stylesheet, "version" => "1.0" do
xml.xsl "apply-templates", "select" => "cats" do
...
end
end
(I hope that works. :-))
···
Many thanks,
Keith
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
Did you try xml.xsl :variable, "name" => "cats" ?
Ah, that works great. (How can I not have tried that...?)
xml.tag! "apply-templates"
Yep, that's good.
xml.xsl :stylesheet, "version" => "1.0" do
xml.xsl "apply-templates", "select" => "cats" do
...
end
end
Ah, do, instead of a { |block| }...
Alas, it gives me:
xsl:stylesheet version="1.0">
<xsl select="cats">apply-templates</xsl>
</xsl:stylesheet>
But it led me to this hack:
xml.xsl :stylesheet, "version" => "1.0" do
xml.tag! 'xsl:apply-templates select="cats"'
end
Which works!
Thanks a bunch!
Other responses on how to do this better still happily accepted :-).
Thanks,
Keith
···
On Thursday 01 September 2005 12:25 pm, Christian Neukirchen wrote:
Keith Fahlgren <keith@oreilly.com> writes:
xml.xsl :stylesheet, "version" => "1.0" do
xml.xsl "apply-templates", "select" => "cats" do
...
end
end
Ah, do, instead of a { |block| }...
Alas, it gives me:
xsl:stylesheet version="1.0">
<xsl select="cats">apply-templates</xsl>
</xsl:stylesheet>
Interesting... oh, I forgot a :
xml.xsl :stylesheet, "version" => "1.0" do
xml.xsl :"apply-templates", "select" => "cats" do
... #^^^
end
end
But it led me to this hack:
xml.xsl :stylesheet, "version" => "1.0" do
xml.tag! 'xsl:apply-templates select="cats"'
end
Which works!
Really a hack. Yuck.
Thanks a bunch!
You're welcome.
···
Keith
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
Interesting... oh, I forgot a :
xml.xsl :stylesheet, "version" => "1.0" do
xml.xsl :"apply-templates", "select" => "cats" do
... #^^^
end
end
Hooray! You get 20pts for answering a quesiton while I was writing the
email asking it.
Really a hack. Yuck.
Yeah, it doesn't really work except for one-line tags.
Here's an example of the problem:
<xsl:variable name="elem-contents">
<xsl:value-of select="substring(., 2, $end-pos)"/>
</xsl:variable name="elem-contents">
Thanks again,
Keith
···
On Thursday 01 September 2005 3:08 pm, Christian Neukirchen wrote: