substring-after and substring-before 2003-05-21 - By Christine Li
Hi, Corneil
I can't reproduce any error. What is your expected result? I modified your stylesheet to execute the substring-before and substring-after functions:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dsml ="http://www.dsml.org/DSML" version="1.0"> <xsl:output method="text" encoding="UTF-8" media-type="text/txt" omit-xml-declaration="yes" /> <xsl:param name="searchdn" select="string('')"/> <xsl:param name="replacedn" select="string('')"/> <xsl:template match="/"> <xsl:if test="string-length($searchdn) != 0"> <xsl:message>Replacing <xsl:value-of select="$searchdn"/> with <xsl:value-of select="$replacedn"/></xsl:message> </xsl:if> <xsl:apply-templates select= "dsml:dsml/dsml:directory-entries/dsml:entry"/> <xsl:text disable-output-escaping="yes">
</xsl:text> </xsl:template> <xsl:template match="dsml:entry" name="entry"> <xsl:if test="string-length($searchdn) = 0"> <xsl:text disable-output-escaping="yes">
dn: </xsl:text > 0<xsl:value-of select="@(protected)"/> 1<xsl:value-of select="substring-before(@(protected),$searchdn)"/> 2<xsl:value-of select="substring-after(@(protected),$searchdn)"/> 3<xsl:value-of select= "concat(substring-before(@(protected),$searchdn),$replacedn,substring-after(@(protected), $searchdn))" /> </xsl:if>
</xsl:template> </xsl:stylesheet>
As far as I can tell, the result is correct. I got the same result using both Xalan interpretive and xsltc.
dn: 0cn=config,ou=dummy2,o=dummycorp.com 1 2cn=config,ou=dummy2,o=dummycorp.com 3cn=config,ou=dummy2,o=dummycorp.com dn: 0cn=xyz,cn=config,ou=dummy2,o=dummycorp.com 1 2cn=xyz,cn=config,ou=dummy2,o=dummycorp.com 3cn=xyz,cn=config,ou=dummy2,o=dummycorp.com dn:
0cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com 1
2cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com
3cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com dn:
0cn=inputParams,cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com 1
2cn=inputParams,cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com
3cn=inputParams,cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com
Christine Li XSLT Development IBM Toronto Lab Tel: (905)413-2601 Email: jycli@(protected)
"du Plessis, Corneil C" To: Christine Li/Toronto /IBM@(protected), <CAduPlessis1@(protected) cc: c.co.za> Subject: RE: substring-after and substring-before 05/21/2003 10:08 AM
In response to Christine Li:
Ant Task:
<style style="dsml2ldif.xsl" processor="trax" force="{dsml.stylesheetnew}" includes="**/*.dsml" excludes="**/*_test.dsml" extension="_test.ldif" destdir=".">
<param name="searchdn" expression="'ou=dummy2'"/> <param name="replacedn" expression="'ou=dummy2_test'"/> </style>
Here is a short xml file:
<dsml xmlns="http://www.dsml.org/DSML" xmlns:bcml=" http://www.sbsa.com/2002/BCML"> <!-- Name: statements--> <!-- Version: 1.0--> <!-- Container: dummy2--> <!-- Domain: dummycorp.com--> <directory-entries> <!--Entry should be created by administrator. dn: ou=dummy2,o=dummycorp.com--> <!--Configuration--> <entry dn="cn=config,ou=dummy2,o=dummycorp.com"> <objectclass> <oc-value>top</oc-value> <oc-value>container</oc-value> </objectclass> <attr name="cn"> <value>config</value> </attr> </entry> <entry dn="cn=xyz,cn=config,ou=dummy2,o=dummycorp.com"> <objectclass> <oc-value>top</oc-value> <oc-value>container</oc-value> </objectclass> <attr name="cn"> <value>globus</value> </attr> </entry> <entry dn="cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp.com"> <objectclass> <oc-value>top</oc-value> <oc-value>cimManagedElement</oc-value> <oc-value>cimConfiguration</oc-value> <oc-value>ePropertySet</oc-value> </objectclass> <attr name="cid"> <value>statement_config</value> </attr> </entry> <entry dn="cn=inputParams,cid=statement_config,cn=xyz,cn=config,ou=dummy2,o=dummycorp .com">
<objectclass> <oc-value>top</oc-value> <oc-value>container</oc-value> </objectclass> <attr name="cn"> <value>inputParams</value> </attr> </entry> </directory-entries> </dsml>
-----Original Message----- From: Christine Li [mailto:jycli@(protected)] Sent: 21 May, 2003 15:27 To: du Plessis, Corneil C Cc: xalan-j-users@(protected) Subject: Re: substring-after and substring-before
Hi, Corneil
With your stylesheet only, there is not enough information for me to tell whether it is a problem of your stylesheet or it is a bug in substring-after function. Would you please provide your xml file as well?
Christine Li XSLT Development IBM Toronto Lab Tel: (905)413-2601 Email: jycli@(protected)
"du Plessis,
Corneil C" To: xalan-j-users@(protected)
<CAduPlessis1@(protected) cc:
c.co.za> Subject: substring-after and substring-before
05/21/2003 04:49
AM
I have a problem with substring-before and substring-after.
A transformation that worked with Xalan 1.x stopped working when I moved up
to 2.x I have tried 2.5.0 and 2.4.1 with no success.
Has anyone experienced a similar problem? Am I doing someting wrong?
This XSL converts DSML to LDIF and will optionaly replace a portion of a DN
with a new value. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dsml="http://www.dsml.org/DSML" version="1.0"> <xsl:output method="text" encoding="UTF-8" media-type="text/txt" omit-xml-declaration="yes" /> <xsl:param name="searchdn" select="string('')"/> <xsl:param name="replacedn" select="string('')"/> <xsl:template match="/"> <xsl:if test="string-length($searchdn) != 0"> <xsl:message>Replacing <xsl:value-of select="$searchdn"/> with <xsl:value-of select="$replacedn"/></xsl:message>
</xsl:if> <xsl:apply-templates select="dsml:dsml/dsml:directory-entries/dsml:entry"/> <xsl:text disable-output-escaping="yes">
</xsl:text> </xsl:template> <xsl:template match="dsml:entry" name="entry"> <xsl:if test="string-length($searchdn) != 0"> <xsl:text disable-output-escaping="yes">
dn: </xsl:text><xsl:value-of select="concat(substring-before(@(protected),$searchdn),$replacedn,substring-after(@(protected), $searchdn))"/>
</xsl:if> <xsl:if test="string-length($searchdn) = 0"> <xsl:text disable-output-escaping="yes">
dn: </xsl:text><xsl:value-of select="@(protected)"/> </xsl:if> <xsl:for-each select="dsml:objectclass/dsml:oc-value"> <xsl:text disable-output-escaping="yes">
objectclass: </xsl:text><xsl:value-of select="text()"/> </xsl:for-each> <xsl:for-each select="dsml:attr/dsml:value"> <xsl:if test="boolean(string-length(text()) > 0) or boolean(normalize-space(text()) != ' ')"> <xsl:text disable-output-escaping="yes">
</xsl:text><xsl:value-of select="../@(protected)"/>: <xsl:value-of select="text()"/>
</xsl:if> </xsl:for-each> <xsl:text disable-output-escaping="yes">
</xsl:text> </xsl:template> </xsl:stylesheet>
Corneil du Plessis Technical Specialist Internet Development Retail Channels Standard Bank Direct +27 (11) 636-2210 Mobile +27 (83) 442-9221 ICQ# 66747137
_______________________________________________________________________________ ___________________________________________________
For information about the Standard Bank group visit our web site < www.standardbank.co.za> _______________________________________________________________________________ ___________________________________________________
Disclaimer and confidentiality note Everything in this e-mail and any attachments relating to the official business of Standard Bank Group Limited is proprietary to the group. It is confidential, legally privileged and protected by law. Standard Bank does not own and endorse any other content. Views and opinions are those of the sender unless clearly stated as being that of the
group. The person addressed in the e-mail is the sole authorised recipient. Please
notify the sender immediately if it has unintentionally reached you and do not read, disclose or use the content in any way. Standard Bank can not assure that the integrity of this communication has been maintained nor that it is free of errors, virus, interception or interference. _______________________________________________________________________________ ____________________________________________________
_______________________________________________________________________________ ___________________________________________________ For information about the Standard Bank group visit our web site < www.standardbank.co.za> _______________________________________________________________________________ ___________________________________________________
Disclaimer and confidentiality note Everything in this e-mail and any attachments relating to the official business of Standard Bank Group Limited is proprietary to the group. It is confidential, legally privileged and protected by law. Standard Bank does not own and endorse any other content. Views and opinions are those of the sender unless clearly stated as being that of the group. The person addressed in the e-mail is the sole authorised recipient. Please notify the sender immediately if it has unintentionally reached you and do not read, disclose or use the content in any way. Standard Bank can not assure that the integrity of this communication has been maintained nor that it is free of errors, virus, interception or interference. _______________________________________________________________________________ ____________________________________________________
|
|