I tried what you suggested, David (C), modulo the remark from David (P).
(As David (P) mentioned, you can't put '<' characters in the middle of
a Xpath literal string, so I just removed part from your example.)
That brings me to this example stylesheet:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" >
<xsl:output indent="yes" encoding="UTF-8" method="xml" />
<xsl:template match="/" name="main" >
<root rootAttribute="example">
<xsl:text> </xsl:text >
<xsl:comment select="'Here is my comment.'" />
<xsl:text> </xsl:text>
<property example1="example1" />
<property example2="example2" />
</root>
</xsl:template>
</xsl:stylesheet>
With this result:
<?xml version="1.0" encoding="UTF-8"?>
<root rootAttribute="example">
<!--Here is my comment.-->
<property example1="example1"/>
<property example2="example2"/>
</root>
Which, in the end, has both the comment line and and property line at
the wrong indentation level (should both be at same level as property
with attribute example2).
The following "works", or produces the correct output, but I contend that
adding the extra text nodes isn't very readable, and manually counting spaces
is not intellectually gratifying, not to mention fastdious and error-prone.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0" >
<xsl:output indent="yes" encoding="UTF-8" method="xml" />
<xsl:template match="/" name="main" >
<root rootAttribute="example">
<xsl:text>  	</xsl:text>
<xsl:comment select="'Here is my comment.'" />
<xsl:text>  	</xsl:text>
<property example1="example1" />
<property example2="example2" />
</root>
</xsl:template>
</xsl:stylesheet>
I guess that I'm really expecting the simple case to work, where indentation
comes out as a function of nested children without having
to add extraneous text nodes.
Thanks for the help
-alan
----- Original Message -----
From: "M. David Peterson" [m(_dot_)david(_at_)xmlhacker(_dot_)com]
Sent: 06/07/2008 04:41 CST
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] How to get comments to indent on their own line in XML
output?
On Sun, 06 Jul 2008 04:08:51 -0600, David Carlisle
<davidc(_at_)nag(_dot_)co(_dot_)uk>
wrote:
<xsl:text> </xsl:text>
<xsl:comment select="'Here<xsl:text> </xsl:text>xu is my comment.'"
/>
<xsl:text> </xsl:text>
I assume you meant:
<xsl:text> </xsl:text>
<xsl:comment>Here is my comment.</xsl:comment>
<xsl:text> </xsl:text>
Either that, or I missed the errata for both the XML and XSLT specs that
allow embedding markup into attributes and the addition of the select
attribute to xsl:comment, respectively. ;-)
--
/M:D
M. David Peterson
Co-Founder & Chief Architect, 3rd&Urban, LLC
Email: m(_dot_)david(_at_)3rdandUrban(_dot_)com |
m(_dot_)david(_at_)amp(_dot_)fm
Mobile: (206) 999-0588
http://3rdandUrban.com | http://amp.fm |
http://www.oreillynet.com/pub/au/2354
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
****************************************************************
Ce message a ete transmis par Internet. Son emetteur peut ne pas etre
l'emetteur annonce. Son contenu et toute piece jointe peuvent ne pas etre
exacts.
This message originated from the Internet. Its originator may or may not be who
they claim to be and information contained in the message and any attachments
may or may not be accurate.
Ensemble adoptons des gestes responsables : N'imprimez ce mail que si
necessaire.
Les informations contenues dans ce message et les pieces jointes (ci-apres
denomme le message) sont confidentielles et peuvent etre couvertes par le
secret professionnel. Si vous n'etes pas le destinataire de ce message, il vous
est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser
tout ou partie. Si vous avez recu ce message par erreur, nous vous remercions
de le supprimer de votre systeme, ainsi que toutes ses copies, et d'en avertir
immediatement HSBC France et ses filiales par message de retour. Il est
impossible de garantir que les communications par messagerie electronique
arrivent en temps utile, sont securisees ou denuees de toute erreur,
alteration, falsification ou virus. En consequence, HSBC France et ses filiales
declinent toute responsabilite du fait des erreurs, alterations, falsifications
ou omissions qui pourraient en resulter.
Consider the environment before printing this mail.
The information contained in this e-mail is confidential. It may also be
legally privileged. If you are not the addressee you may not copy, forward,
disclose or use any part of it. If you have received this message by error,
please delete it and all copies from your system and notify the sender
immediately by return e-mail. E-mail communications cannot be guaranteed to be
timely secure, error or virus-free. The sender does not accept liability for
any errors or omissions which arise as a result.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--