Problem

A Forum reader recently asked:

“I’m looking to modify an existing stylesheet that writes a custom string attribute into eDirectory. It changes the content of this attrib from a free-form string to an XML string. I want the equivalent of a DirXML script “token-xml-serialize” in XSLT / XPATH.

Basically, I’m looking to reverse this Cool Solution:
http://www.novell.com/coolsolutions/tip/15175.html

And here’s the response from Father Ramon …

Solution

Try this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
xmlns:domwriter="http://www.novell.com/nxsl/java/com.novell.xml.dom.DOMWriter"
   xmlns:stringwriter="http://www.novell.com/nxsl/java/java.io.StringWriter"
   xmlns:exsl="http://exslt.org/common"
   exclude-result-prefixes="domwriter stringwriter exsl" >
<xsl:template match="/">

   <xsl:variable name="mynode-set">
     <node1 attr1="test" attr2="moretext">
       <node1 attr3="text"/>
     </node1>
   </xsl:variable>

   <xsl:variable name="stringWriter" select="stringwriter:new()"/>
   <xsl:variable name="domWriter" 
select="domwriter:new(exsl:node-set($mynode-set), $stringWriter)"/>
   <xsl:variable name="temp" select="domwriter:write($domWriter)"/>
   <xsl:variable name="serialized" 
select="stringwriter:toString($stringWriter)"/>
   <xsl:value-of select="$serialized"/>
</xsl:template>

</xsl:stylesheet>

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading...Loading...
Categories: Uncategorized

Disclaimer: As with everything else at NetIQ Cool Solutions, this content is definitely not supported by NetIQ, so Customer Support will not be able to help you if it has any adverse effect on your environment.  It just worked for at least one person, and perhaps it will be useful for you too.  Be sure to test in a non-production environment.

Leave a Reply

No Comments
netiqcoolguys
Dec 26, 2007
6:38 pm
Reads:
1,101
Score:
Unrated