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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + sort by variable (11)
-> + [XSLT Recursive Template Help]... (2)
-> + Adding values with document() ... (7)
-> + merging xml files in to single... (2)
-> + Limit description characters i... (2)
-> + problem parsing xml as text in... (2)
-> + Summarize/Distinct (5)
-> + unix epoch seconds to date str... (3)
-> - xml, xslt question (5)
-> ->xml, xslt question
-> ->xml, xslt question
-> ->xml, xslt question
-> ->xml, xslt question
-> + LGCL XSLT transformation (3)
-> + Dynamic include (3)
-> + .rdbxml as XML within Stylus ... (3)
-> + Array of Values From XSL (2)
-> + Problem Saving output (2)
-> + Base 64 encoded data embedded ... (2)
-> + XML-XML Mapping (2)
-> - Parameterized 'Document()' ...... (1)
-> + Newbie prob - Elements with sa... (3)
-> - .net 1.1 incorrectly processin... (1)
-> + xs:key and xs:keyref question (5)
-> + pass xsl-variable to javascrip... (2)
-- Previous [1321-1340] [1341-1360] [1361-1380] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Rahul PuttaguntaSubject: xml, xslt question
Author: Rahul Puttagunta
Date: 03 Oct 2006 07:29 PM
Originally Posted: 03 Oct 2006 07:26 PM
Would you please help me create an xsl stylesheet?

I need to transform this xml using an xslt stylesheet. I basically need to trim spaces from the attributes and then save it into another xml file.
Since the post is trimming it for me, I am replacing the spaces with
X's.

Source:

<searchresults>

<v w="21XXXXXXXXXXXXXXXXX">
<f n="BrandCode" v="1XXXXXXXXXXXXXXX"/>
<f n="state" v="AKXXXXXXXXXXXXXXXXXX"/>
<f n="city" v="AnchorageXXXXXXXXXXX"/>
<f n="name" v="name1"/>


</v>
<v w="21">
<f n="BrandCode" v="7"/>
<f n="state" v="AKXXXXXXXXXXXXXXXXX"/>
<f n="city" v="FairbanksXXXXXXXXXXXXXXXXXXX"/>
<f n="name" v="name2"/>

</v>
</searchresults>


Result:

<searchresults>

<v w="21">
<f n="BrandCode" v="1"/>
<f n="state" v="AK"/>
<f n="city" v="Anchorage"/>
<f n="name" v="name1"/>


</v>
<v w="21">
<f n="BrandCode" v="7"/>
<f n="state" v="AK"/>
<f n="city" v="Fairbanks"/>
<f n="name" v="name2"/>

</v>
</searchresults>

Your help is greatly appreciated.

Postnext
Rahul PuttaguntaSubject: xml, xslt question
Author: Rahul Puttagunta
Date: 04 Oct 2006 12:54 PM
bump ....


I guess i just need the XSL transformation that THIS particular forum is doing for trimming the attribute spaces on my XML.

Thank you,
Rahul.

Postnext
James DurningSubject: xml, xslt question
Author: James Durning
Date: 05 Oct 2006 05:52 PM
Originally Posted: 05 Oct 2006 05:51 PM
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="translate(.,' ','')
</xsl:attribute>
</xsl:template>

you could also use normalize-space()

Postnext
Rahul PuttaguntaSubject: xml, xslt question
Author: Rahul Puttagunta
Date: 06 Oct 2006 04:10 PM
Thank you, but the XSL you gave me look like they are two different XSL's . Also, one of the two xml's was not well formed. Can you help me out please?

Thank you,
Rahul.

Posttop
Rahul PuttaguntaSubject: xml, xslt question
Author: Rahul Puttagunta
Date: 09 Oct 2006 10:57 AM
My friend posted this in a google groups forum, and, somebody answered. Here is the solution:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="searchresults" mode="normalize"/>
</xsl:template>
<xsl:template match="node()" mode="normalize">
<xsl:copy >
<xsl:apply-templates select="@*" mode="normalize"/>
<xsl:apply-templates select="*" mode="normalize"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*" mode="normalize">
<xsl:attribute name="{name(.)}">
<xsl:value-of select="normalize-space(.)"/>
</xsl:attribute>
</xsl:template>

   
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.