|
-
Jun 21st, 2006, 11:41 AM
#1
New Member
Re: Indent XML (without recursion)
Your XSL based code works great, but there is one change I'm having some trouble implementing. What needs to change in the XSL file in order to not add an end tag? For example,
I don't want this:
<element attribute="value"/>
to be changed to this:
<element attribute="value">
</element>
I know it's just a matter of figuring out the XSL syntax, but I don't have time to learn XSL just to make this one change. Thanks for the help.
-
Jan 17th, 2007, 02:38 AM
#2
New Member
Re: Indent XML (without recursion)
 Originally Posted by takedownca
Your XSL based code works great, but there is one change I'm having some trouble implementing. What needs to change in the XSL file in order to not add an end tag? For example,
I don't want this:
<element attribute="value"/>
to be changed to this:
<element attribute="value">
</element>
I know it's just a matter of figuring out the XSL syntax, but I don't have time to learn XSL just to make this one change. Thanks for the help.
I changed the XSL_FILE to the following, and it appears to have solved the problem. I haven't debugged it, but it works for me. Not exactly sure why it works, though. My XPath and XSL is pretty rusty.
VB Code:
XSL_FILE = _
"<?xml version=" & QT & "1.0" & QT & " encoding=" & QT & "UTF-8" & QT & "?>" & vbCrLf & _
"<xsl:stylesheet version=" & QT & "1.0" & QT & " xmlns:xsl=" & QT & "http://www.w3.org/1999/XSL/Transform" & QT & ">" & vbCrLf & _
" <xsl:output method=" & QT & "xml" & QT & " version=" & QT & "1.0" & QT & " encoding=" & QT & "UTF-8" & QT & " indent=" & QT & sIndent & QT & "/>" & vbCrLf & _
" <xsl:template match=" & QT & "@* | node()[count(*)>0]" & QT & ">" & vbCrLf & _
" <xsl:copy>" & vbCrLf & _
" <xsl:apply-templates select=" & QT & "@* | node()" & QT & " />" & vbCrLf & _
" </xsl:copy>" & vbCrLf & _
" </xsl:template>" & vbCrLf & _
" <xsl:template match=" & QT & "node()[count(*)=0]" & QT & ">" & vbCrLf & _
" <xsl:copy>" & vbCrLf & _
" <xsl:apply-templates select=" & QT & "@*" & QT & " />" & vbCrLf & _
" </xsl:copy>" & vbCrLf & _
" </xsl:template>" & vbCrLf & _
"</xsl:stylesheet>"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|