• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. XML in SKILL

Stats

  • Locked Locked
  • Replies 11
  • Subscribers 144
  • Views 20562
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

XML in SKILL

ToMWUT
ToMWUT over 16 years ago
Hello All,
In my SKILL++ application I have to store some configuration data on my local hard drive. My question now is how to do this? In standard programming languages I’d use an XML file. Is it possible to use XML in SKILL or maybe I would have to write all parsing of the XML by my own? If the last possibility is valid than only simple text file (values separated by ; for example) is left as a solution, am I right?
Thanks,
ToM
  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 16 years ago

    In case anyone is interested, I just put together an XSLT stylesheet which will convert XML into a format that is easily parsable in SKILL.

    You need to do: xsltproc xmlToSKILL.xsl yourXML.xml > skillFriendly.txt

    Then the resulting file can be read by doing:

    prt=infile("skillFriendly.txt")
    data=lineread(prt)
    close(prt)
    data=car(data)
    

    You'll find that the head of each list is the name of the element, and the cadr() is a DPL containing any attribute-value pairs, and the rest of each list is all the text contents or sub-elements.

    And finally here's the XSLT stylesheet (xmlToSKILL.xsl). Hopefully I can get this to display OK on the forum! Note, this has mangled some of the quotation marks, so it's for viewing only. Please download the attachment.

    <?xml version="1.0"?>
    <!--
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   XSLT
    Date       Jul 16, 2009 
    Modified   
    By         
    
    XSLT stylesheet to transform XML into a format that can easily be
    parsed by SKILL.
    
    Use: xsltproc thisStyleSheet.xsl xmlFile
    
    and the resulting file should be easily readable with lineread in SKILL.
    
    ***************************************************
    
    SCCS Info: @(#) xmlToSKILL.xsl 07/16/09.14:13:25 1.1
    
    -->
    <xsl:stylesheet xmlns:xsl="">www.w3.org/.../Transform" version="1.0">
    
    <xsl:output method="text"/>
    
    <!-- Match all top level nodes -->
    <xsl:template match="*">
      <xsl:text>(</xsl:text><xsl:value-of select="name()"/><xsl:text> </xsl:text>
      <!-- output a DPL of all attributes -->
      <xsl:text>(nil </xsl:text><xsl:apply-templates select="@*"/><xsl:text>) </xsl:text>
      <!-- next any text nodes -->
      <xsl:apply-templates select="text()"/>
      <!-- and finally call recursively to find descendents -->
      <xsl:apply-templates select="*"/>
      <xsl:text>)
    </xsl:text>
    </xsl:template>
    
    <!-- Match and format attributes -->
    <xsl:template match="@*">
      <xsl:value-of select="name()"/>
      <xsl:text> "</xsl:text>
      <xsl:call-template name="translateDoubleQuotes">
        <xsl:with-param name="string" select="."/>
      </xsl:call-template>
      <xsl:text>" </xsl:text>
    </xsl:template>
    
    <!-- Match and format text nodes -->
    <xsl:template match="text()">
      <!-- check to see if text node is non-empty -->
      <xsl:if test="string-length(normalize-space(.))">
        <xsl:text>"</xsl:text>
        <xsl:call-template name="translateDoubleQuotes">
          <xsl:with-param name="string" select="."/>
        </xsl:call-template>
        <xsl:text>" </xsl:text>
      </xsl:if>
    </xsl:template>
    
    <!-- escape any double quotes -->
    <xsl:template name="translateDoubleQuotes">
      <xsl:param name="string" select="''" />
      <xsl:choose>
        <xsl:when test="contains($string, '"')">
          <xsl:value-of select="substring-before($string, '"')" />
          <xsl:text>\"</xsl:text>
          <xsl:call-template name="translateDoubleQuotes">
    	<xsl:with-param name="string" select="substring-after($string, '"')" />
          </xsl:call-template><xsl:text />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$string" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    
    </xsl:stylesheet>
    

    Regards,

    Andrew.

    https://community.cadence.com/cfs-file/__key/communityserver-discussions-components-files/48/xmlToSKILL.xsl

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mantang
    mantang over 7 years ago in reply to Andrew Beckett

    Hi

    Where can I find  "xsltproc" ? Is it a build-in function ?

    Thanks,

    ManChak 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • mantang
    mantang over 7 years ago in reply to Andrew Beckett

    Hi

    Where can I find  "xsltproc" ? Is it a build-in function ?

    Thanks,

    ManChak 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to mantang

    It's a UNIX command in /usr/bin/xlstproc and it is provided by the "libxslt" RPM.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mantang
    mantang over 7 years ago in reply to Andrew Beckett

    Hi Andrew,

    Thank you for your info. I guess IT does not install libxslt, so I cannot test it.

    ls /usr/bin/xlstproc
    ls: cannot access /usr/bin/xlstproc: No such file or directory

    Thanks,

    ManChak

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information