Article

anonymous's picture
article
Reads:

3340

Score:
0
0
 
Comments:

0

Writing Custom Strings into eDirectory

Author Info

26 December 2007 - 6:38pm
Submitted by: anonymous (not verified)

Tags

Tip

(View Disclaimer)

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>


Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).

It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.




User Comments

© 2013 Novell