A couple of approaches come to mind. Both approaches assume that all other transformations are complete and that you have an XML string on which to do the work. Also, both solutions would be a Java service, expecting a valid incoming XML string and an outgoing pseudo-XML string.
-
Parse the incoming string yourself. You only need to look for tags. For each tag (search for ‘<’ and then ‘>’) search for ‘=’. If ‘=’ is present, reformat the tag, jamming all the attributes together and write it to the output string. Transfer everything else over to the output string directly.
-
Use a SAX or DOM parser to parse the incoming string. Then output the XML, outputting tags/attributes in the way that you need. The SAX parser would probably be the way to go as you can create a SAX ContentHandler interface to write the target string in the format you want. DOM will create a complete parse tree of the entire document in memory, which may be okay if your doc isn’t huge. Whichever one you are comfortable with will work fine. If you’ve not used either, I would suggest SAX.
Hope this helps. I could probably throw a solution together, using either approach, if you’d like. Let me know which one you’d like to use and the details of the attribute munging (i.e. what to do if there are multiple attributes).