Hi guys, I am playing with vuejs and I am sucked with a xslt issue. Here is the kind of markup needed by vuejs for exemple:

<button id="show-modal" @click="showModal = true">Show Modal</button>

This could be great but I didn't find any way to render a at sign inside the name of the attribute, so there is another possible syntax:

<button id="show-modal" v-on:click="showModal = true">Show Modal</button>

It's a kind of namespace but without the declaration, any idea about how this can be achieved with xslt? with the @ or with the : in an attribute?

I found half of the answer using namespaces, adding the definition at the top of the stylesheet let me use v-on in the template:


Then, using the html5_doctype (in extension driver file) I added a regexp to delete the declaration, like that:

$html_doctype = preg_replace('/ xmlns:v-on=""/', '', $html_doctype);

But for the challenge, any idea if it s possible to include the @ in the attribute name? Or due to the parser and XPATH nature of @ there is absolutely no way to output this markup:

<button id="show-modal" @click="showModal = true">Show Modal</button>

Another way to stop the namespace declaration appearing in the output is to put exclude-result-prefixes="v-on" in the stylesheet declaration.

I just wanted to delete the schema definition in html tag. The "prefixes" of attributes are needed for directives of vuejs. It uses a weird syntax, but anyway it works, I just can't use the shorthands as starting an attribute name with ":" or "@" seems impossible with xslt.

You can not have attribute names in XML starting with an "@", because these are not valid QNames.

However, I wouldn't give up too fast on the alternative syntax.

Why do you want to delete the namespace declaration? If an attribute has a namespace, it must be declared.

If you use xmlns:v-on="" in your stylesheet element, you can do:

    <xsl:attribute name="v-on:click">hello</xsl:attribute>


<test v-on:click="hello"/>

and the result will be:

<test xmlns:v-on="" v-on:click="hello"></test>

(Note that it depends on the output type if the element test will be self-closing or not.)

What's wrong with that?

Thanks Michael it s ok it works, and it s the only way. To have a final code more readable I wanted to hide the xmlns declarations, and that can be done modifying the html5 doctype extension.

Please note that if you remove the namespace declaration, your code will no longer be valid XML.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details