cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Correct Xpath expression to remove special characters

SOLVED
Highlighted
Level 1

Correct Xpath expression to remove special characters

Recently we've been experiencing some issues when bursting an Editor document into Windchill. Apparently, special characters such as ':,>' etc. are not allowed within Windchill object names. So I've found the following Xpath code (to be inserted in the burst configuration naming rules) which should be able to substitute any special characters when names are generated:

<namerule elementname="map" rule="xpath" nameexpression="translate(title/@outputclass,' \*Smiley Sad)|&lt;&gt;%.?/&quot;&apos;',' ')"/>

I cannot however get it to work. If anyone is familiar with Xpath syntax, could you please provide an example of how this code would look when using it to substitute characters in chapter object names? I suspect the issue lies with the 'title/@outputclass' part of the code, since I have tried for example 'title/chapter' and many other variations with no luck...

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Correct Xpath expression to remove special characters

Hi Trevor,

Thank you for your answer I really appreciate it! I actually got a namehook ACL function to replace the unnecessary characters:

<namehook sourcetype="text" type="acl">
<![CDATA[
# override default rules to replace all
# spaces with underscores in text object names.
function name_hook::text_location_hook()
{
local name=dms::burst_hook_value();
gsub(' ', '_', name);
dms::set_burst_hook_value(name);
}

name_hook::text_location_hook();
]]>
</namehook>

I just inserted the characters I want replaced instead of the 'space'.

Regards,

2 REPLIES

Re: Correct Xpath expression to remove special characters

First I need to admit I haven't done bursting yet, so this is strictly an xpath response.

In regards to the translate function, I made this error as well. Translate works to replace one character with another (http://www.xsltfunctions.com/xsl/fn_translate.html). The function it looks like you're wanting is replace (http://www.xsltfunctions.com/xsl/fn_replace.html) which is not available in xpath 1.0. Not sure what version is used with the burst configuration.

Note that with your example, assuming replace is a recognized function, your line gets considerably longer as you can only apply the change to one at a time.

Below is the start so you get the idea. This will remove quotes and less than named entities from your string (which appears to be what you were doing above).

replace(replace(title/@outputclass, '&quot;', ''), '&lt;', '')

Re: Correct Xpath expression to remove special characters

Hi Trevor,

Thank you for your answer I really appreciate it! I actually got a namehook ACL function to replace the unnecessary characters:

<namehook sourcetype="text" type="acl">
<![CDATA[
# override default rules to replace all
# spaces with underscores in text object names.
function name_hook::text_location_hook()
{
local name=dms::burst_hook_value();
gsub(' ', '_', name);
dms::set_burst_hook_value(name);
}

name_hook::text_location_hook();
]]>
</namehook>

I just inserted the characters I want replaced instead of the 'space'.

Regards,