DEV Community

Paul Lefebvre
Paul Lefebvre

Posted on

6 1

Format XML with XSLT

Did you know you can use XSLT to format your XML so that it is more readable? XSLT stands for eXtensible Stylesheet Language. This XSLT can be used to format XML:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:copy-of select="/" />
</xsl:template>
</xsl:transform>
Enter fullscreen mode Exit fullscreen mode

Apply this XSLT to your XML using whatever XSLT Transformation command is available to you.

To use this XSLT with Xojo, add a module to your project (name it XMLExtensions), add a String constant to the module (call it kXSLTFormat) and copy the above XSLT into the constant.

Now add a Global function to the module that extends the XMLDocument class with a Format function:

Function Format(Extends xml As XMLDocument) As String
  Return xml.Transform(kXSLTFormat)
End Function
Enter fullscreen mode Exit fullscreen mode

Now you can call it to get back formatted XML as a String. For example, this code takes unformatted XML from a TextField and displays the formatted XML in another TextField:

Dim xml As New XMLDocument
xml.LoadXml(TextArea1.Text)
TextArea2.Text = xml.Format
Enter fullscreen mode Exit fullscreen mode

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay