XML is the standard way of representing and storing rapidly-growing semi-structured data on the Internet. While XQuery has been proposed by W3C as the standard query language for XML data, the complexity of the language is the major overhead for users to express the queries and for software to process the queries efficiently. Considering mobile devices are more popular than desktop computers, expressing and/or processing XQuery becomes even more cumbersome on mobile devices. This paper proposes a visual XQuery specification language called VXQ. By intuitive abstractions of XML and XQuery, the proposed system can generate XQuery queries for users with little knowledge about XML and the language. The proposed visual language is easier to use and more expressive than previous proposals, and is also suitable for mobile devices where typing is not desired. Furthermore, we extend our proposed visual XQuery to support query rewriting and optimization for multiple XQuery systems. Experiments show that, in practice, our query rewriting reduces the query execution time significantly.