[xslt] newline in attr value



Hi,
I would really appreciate your help on this.

I want to get the newlines in my
attribute values (set using xmlSetProp
while populating an XML tree) appear
as 
 after transformation through
an XSL (in HTML output mode). Is this
possible? Right now this appears as \n
which is not good for me because I want
to display the newline in the browser.

I also noticed that GNOME
does not transform attribute values with
newlines properly in xml output method. Is there
a fix available for this?

Example program attached:
#include <libxml/tree.h>

extern int xmlLoadExtDtdDefaultValue;

int
main(int argc, char** argv) {
  xmlDocPtr doc = NULL;
  xmlNodePtr node = NULL;

  xmlSubstituteEntitiesDefault(1);
  xmlLoadExtDtdDefaultValue = 1;

  doc = xmlNewDoc(BAD_CAST "1.0");
  node = xmlNewDocNode(doc,NULL,BAD_CAST
"TestNode",NULL);
  xmlSetProp(node,BAD_CAST "testattr",BAD_CAST "gnome
\n linux");
  xmlAddChild((xmlNodePtr)doc,node);

  xmlSaveFile("test.xml",doc);
}
  
This generates test.xml
<?xml version="1.0"?>
<TestNode testattr="gnome 
 linux"/>

When transformed using this XSL,

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="TestNode">
<select>
  <xsl:attribute name="onclick">aaaa
	bbbb</xsl:attribute>
</select>
</xsl:template>
</xsl:stylesheet>

gnome produces
<?xml version="1.0" encoding="UTF-8"?>
<select onclick="aaaa
        bbbb"/>

Xalan produces the output below which
seems to be in accordance with section 7.1.3
of XSLT recommendation.
<?xml version="1.0" encoding="UTF-8"?>
<select onclick="aaaa&#10;      bbbb"/>

Are these related problems?

Thanks
madhu




__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]