XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Dana PearsonSubject: non breaking space   in element breaking my stylesheet
Author: Dana Pearson
Date: 10 Feb 2014 04:03 PM
I created a stylesheet that can be used with a XML file that has been converted from an MS Excel spreadsheet. My client does the spreadsheet conversion.

One of the created XML elements is called bisacsubjectcode. The client has sent me a file that breaks portions of my stylesheet with respect to this element.

Some of these elements contain non breaking spaces,   and sometimes an additional normal space, ie, 20; sometimes at the start of the string, sometimes at the end. Only a dozen or so in a file of 140 or so.

It didn't seem a difficult problem. But using strip-space element=bisacsubjectcode does not work.

I then created a character map to replace the   with nothing.
The   is not in the output but it still subverts the object of my constructor. It seems to still effect using substring function.

<xsl:for-each select="bisacsubjectcode">
<datafield tag="072" ind1=" " ind2="7">
<subfield code="a">
<xsl:value-of select="normalize-space(substring(.,1,3))"/>
</subfield>
<subfield code="x">
<xsl:value-of select="normalize-space(substring(.,4,6))"/>
</subfield>
<subfield code="2">bisacsh</subfield>
</datafield>
</xsl:for-each>

Result where two non break spaces at beginning of the string:

<datafield tag="072" ind1=" " ind2="7">
<subfield code="a">F</subfield>
<subfield code="x">IC0270</subfield>
<subfield code="2">bisacsh</subfield>
</datafield>

original element:

<bisacsubjectcode> FIC027020</bisacsubjectcode>

I use the content in different ways, sometimes to evaluate and/or use only a portion of the code and sometimes to match the entire code to an external XML file with subject heading text.

Code format is always the same: 3 alphabetical characters followed by 5 digits.

What am I overlooking here. By the way, is &#xA0; considered white space?

thanks,
Dana Pearson

Posttop
Dana PearsonSubject: non breaking space   in element breaking my stylesheet
Author: Dana Pearson
Date: 10 Feb 2014 04:47 PM
found a solution...used replace function

<xsl:variable name="subject" select="normalize-space(replace(., '&#xA0;', ''))"/>
<datafield tag="072" ind1=" " ind2="7">
<subfield code="a">
<xsl:value-of select="substring($subject,1,3)"/>
</subfield>
<subfield code="x">
<xsl:value-of select="substring($subject,4,6)"/>
</subfield>
<subfield code="2">bisacsh</subfield>
</datafield>

so, &#xA0; is not white space as evidence my attempt to use normalize-space?

Thanks,
Dana Pearson

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.