Builder Question

K

Keith Fahlgren

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
 
K

Keith Fahlgren

Did you try =A0xml.xsl :variable, "name" =3D> "cats" =A0?

Ah, that works great. (How can I not have tried that...?)
xml.tag! "apply-templates"

Yep, that's good.
xml.xsl :stylesheet, "version" =3D> "1.0" do
=A0 xml.xsl "apply-templates", "select" =3D> "cats" do
=A0 =A0 ...
=A0 end
end

Ah, do, instead of a { |block| }...

Alas, it gives me:
xsl:stylesheet version=3D"1.0">
<xsl select=3D"cats">apply-templates</xsl>
</xsl:stylesheet>


But it led me to this hack:

xml.xsl :stylesheet, "version" =3D> "1.0" do
xml.tag! 'xsl:apply-templates select=3D"cats"'
end

Which works!


Thanks a bunch!

Other responses on how to do this better still happily accepted :).


Thanks,
Keith
 
K

Keith Fahlgren

Interesting... oh, I forgot a :

xml.xsl :stylesheet, "version" =3D> "1.0" do
=A0 xml.xsl :"apply-templates", "select" =3D> "cats" do
=A0 =A0 ... #^^^
=A0 end
end

Hooray! You get 20pts for answering a quesiton while I was writing the=20
email asking it.
Really a hack. =A0Yuck. =A0;-)

Yeah, it doesn't really work except for one-line tags.

Here's an example of the problem:
<xsl:variable name=3D"elem-contents">
<xsl:value-of select=3D"substring(., 2, $end-pos)"/>
</xsl:variable name=3D"elem-contents">



Thanks again,
Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top