Subjects
Home
Xalan extension functions
Fomatting question serializing DOM with pretty print
xalan with pull parser
Cannot find the declaration
Apache Xalan drop support to run on JRE 1 1 x
Why does Doctype change processing of a document
Node set to XML string via Java extensions in Xalan J: possible?
Templates/Transformers + thread safety???
Problem evaluating xpath with muliple prefix with different namespace
remove an arbitrary attribute from xsl output
Xalan3 XSLT 2 0 XPath 2 0 support?
Problem using compiled translets with Xalan !!
Xalan and jstl 1 1 problem with transform tag
NullPointer in DOM2DTM getLocalName
URIResolvers base parameter with xsltc and cascaded imports
Performance problem for Xalan J on intel dual core
Standard libraries in JAXP?
Serializing a DOM tree to XML file, customize entities replacement
Library Conflict Involving BCEL Library
A question on how users are using <xsl:message >
Kevin Cormier as a new Apache Xalan J committer
Struggling to iterate over tokenized string
Xalan count() trouble
Problem with recursive xpath
Error when switching to java 1 5
document( ' ')
Problem with Xalan2 7 0 transformation
cr/lf options
entity encoded XML
can xalan transform 2 xml using one xslt?
Xalan J JIRA defect review Monday October 16, 2006 from 2:00 to 3:30 pm ED
xsl transform with cdata section elements
xslt parameters not expanded
Weird behavior of XPath evaluate()
How to avoid <xsl:message > instruction prints stylesheet file informations ?
Cannot find SimpleTransform subdirectory after installing Xalan J
recover from document not found exceptions
jdk1 5 and Xalan jar differences?
Performance Issue
Error/Bug adding floating point numbers
XPathAPI: eval exp using nodes with default namespace
modifying xalan to output invalid XML
NullPointerException
mege two separate xml nodes into one
Is this a XALAN document identification bug?
is StylesheetRoot really java io Serializable ?
transform() fails for DOMSource but succeeds for StreamSource
Thoughts on Transformer parameter passing
HELP, Xalan and jstl 1 1 problem with transformer
Problem with XPath namespace axis?
string utils:replace deleting search string if replacement string is an HTML
help with enumeration values pls
xalan 2 5 1 vs 2 7 performance question
How to insert/update in XML document
HTML Serialization and Handling of Ampersands in HREF Attributes
XHTML link tag stripping
SystemId Unknown; Line #24; Column #49; java lang NullPointerException
xpath text() help
Apostrophe problem with xalan 2 7 0
How to set variables in XML document?
Links
Home
Oracle database error code ...
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
substring-after and substring-before

substring-after and substring-before

2003-05-21       - By Christine Li
Reply:     1     2     3     4     5  





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">&#xA;</xsl:text>
</xsl:template>
<xsl:template match="dsml:entry" name="entry">
       <xsl:if test="string-length($searchdn) = 0">
               <xsl:text disable-output-escaping="yes">&#xA;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">&#xA;</xsl:text>
</xsl:template>
<xsl:template match="dsml:entry" name="entry">
       <xsl:if test="string-length($searchdn) != 0">
               <xsl:text disable-output-escaping="yes">&#xA;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">&#xA;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">&#xA;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">&#xA;</xsl:text><xsl:value-of
select="../@(protected)"/>: <xsl:value-of select="text()"/>





               </xsl:if>
       </xsl:for-each>
       <xsl:text disable-output-escaping="yes">&#xA;</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.
_______________________________________________________________________________
____________________________________________________