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
Ali EbrahimSubject: XSLT Logic to Trucate elements to 250 charaters in an XSD
Author: Ali Ebrahim
Date: 17 Dec 2006 09:50 PM
Hi All,

I'm new to XSLT and Stylus Studio and would like to know how the following is possible.

I have an XSD from my client that has very lengthy <xsd:documentation> elements. Our CRM Product is Siebel and we need to import this external xsd into Siebel. Siebel has a restriction on documentation length to a max of 250 charaters.

Is it possible and if so How do I execute some logic against the external xsd to truncate all <xsd:documentation> to a length of 250 characters in Stylus Studio.

hope I have explained my requirements


Regards,
Ali



Postnext
Ivan PedruzziSubject: XSLT Logic to Trucate elements to 250 charaters in an XSD
Author: Ivan Pedruzzi
Date: 17 Dec 2006 10:40 PM

what follows is a XSLT identity transformation that filters out the documentation text node down to 250 characters.

Ivan Pedruzzi
Stylus Studio Team


<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="*|text()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="xsd:documentation">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="substring(., 1, 250)"/>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>

Postnext
Ali EbrahimSubject: XSLT Logic to Trucate elements to 250 charaters in an XSD
Author: Ali Ebrahim
Date: 17 Dec 2006 11:57 PM
Hello Ivan,


Thanx for all the assistance, it worked well.

This is what I have done....
1) Open Stylus and New>XSL Stylesheet
2) In the Source XML, I selected the XSD that I would like to run the script on
3) In the XSLT Source I pasted in your XSLT script and executed

The script only changed the file I selected.


The client’s schema is made up of a number of xsd and they are included in a main xsd.


Is there anyway by running your xslt script against the main xsd the script, all included xsd's will be looked at and the documentation element will be checked or would your script need to be changed?


The client’s main xsd looks similar to:
<xsd:include schemaLocation="xml_Header_r1.xsd"/>
<xsd:include schemaLocation="xml_Common_r1.xsd"/>
<xsd:include schemaLocation="xml_Loc_r1.xsd"/>
<xsd:include schemaLocation="xml_SP_r1.xsd"/>
<xsd:include schemaLocation="xml_SO_r1.xsd"/>
<xsd:include schemaLocation="xml_SD_r1.xsd"/>
<xsd:include schemaLocation="xml_CR_r1.xsd"/>



Thanx,

Ali

Posttop
Ivan PedruzziSubject: XSLT Logic to Trucate elements to 250 charaters in an XSD
Author: Ivan Pedruzzi
Date: 18 Dec 2006 03:05 PM

You can Invoke the same transformation on a set of XSD files using few lines of Java code.

- Copy Transform.class in the folder where your schemata are
- Open a DOS console in the same folder and execute

java -classpath . Transform <xsl file> *.xsd

The command line generates a new file called

<original name>.new

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


DocumentTransform.class


DocumentTransform.java

 
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.