Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can we use SAS xml map file output the define.xml? #4

Open
zhanglianbo35 opened this issue Jul 31, 2021 · 5 comments
Open

can we use SAS xml map file output the define.xml? #4

zhanglianbo35 opened this issue Jul 31, 2021 · 5 comments

Comments

@zhanglianbo35
Copy link

Input is easy, how about output define.xml?

@jmangori
Copy link
Owner

jmangori commented Aug 3, 2021

I have not been successful doing output. I think it requires a 1:1 relationship between (one) dataset and XML file. This may be a flaw in the XMLMAP technology. Please share if you are successful

@lexjansen
Copy link

I wouldn't so much call it a flaw, but a limitation in the XMLMAP technology. What is supported is to export one SAS dataset to XML using an updated XMLMAP to an XML file. Indeed a 1:1 relationship. . You have to add an OUTPUT element. See: https://documentation.sas.com/doc/en/vdmmlcdc/1.0/engxml/p030dni55gms3qn1xxc7xxpzn06p.htm
Much better in my view is to let existing XML technology like XSLT do the heavy lifting, not SAS. You can can output all datasets to a 'flat' XML file (a cube with structure ) and then use XSL stylesheets to transform that to Define-XML. You can use the same principles for the other way around. These concepts were used in the SAS Clinical Standards Toolkit.

@KatjaGlassConsulting
Copy link
Collaborator

@lexjansen, I remember I tried once to use XLST for tasks but somehow failed. How to automatically use XLST to "render" a define.xml to a CSV file for example? Or how to "render" a flat XML file to create a new XML file with a different format? Do you have an example to share?

@lexjansen
Copy link

By using a different output method (text) XSLT just creates text. For examples of creating text see:
https://www.lexjansen.com/phuse/2010/cd/CD10.pdf
This example creates SAS code from Define-XML.
The SAS Clinical StAndards Toolkit (not being developed anymore) contains stylesheets to transform between Define-XML and a simple XML cube.
Here is an example of turning part of the ODM terminology XML file into CSV:

<xsl:stylesheet xmlns="http://www.cdisc.org/ns/odm/v1.3"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:odm="http://www.cdisc.org/ns/odm/v1.3"
xmlns:nciodm="http://ncicb.nci.nih.gov/xml/odm/EVS/CDISC"
version="2.0">
<xsl:output method="text" encoding="iso-8859-1"/>

<xsl:strip-space elements="*" />

<xsl:template match="/">
xsl:text"Short Name","C-Code","Description","CodeList Extensible","CodedValue","C-Code"</xsl:text>
xsl:text </xsl:text>

<xsl:for-each select="//odm:EnumeratedItem">
  <xsl:sort data-type="text" order="ascending" select="Name"/>
  <xsl:text>"</xsl:text><xsl:value-of select="../nciodm:CDISCSubmissionValue"/><xsl:text>",</xsl:text>
  <xsl:text>"</xsl:text><xsl:value-of select="../@nciodm:ExtCodeID"/><xsl:text>",</xsl:text>
  <xsl:text>"</xsl:text><xsl:value-of select="../odm:Description/odm:TranslatedText"/><xsl:text>",</xsl:text>
  <xsl:text>"</xsl:text><xsl:value-of select="../@nciodm:CodeListExtensible"/><xsl:text>",</xsl:text>
  <xsl:text>"</xsl:text><xsl:value-of select="@CodedValue"/><xsl:text>",</xsl:text>
  <xsl:text>"</xsl:text><xsl:value-of select="@nciodm:ExtCodeID"/><xsl:text>"</xsl:text>
  <xsl:text>&#xa;</xsl:text> 
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

@lexjansen
Copy link

lexjansen commented Mar 28, 2022

This is another example:
https://github.com/lexjansen/sas-papers/tree/master/pharmasug-2018/xslt
It uses XSLT for the heavy lifting and XML maps for converting flat XML to SAS.
I use PROC XSL in this example. This SAS procedure is quite limited though. It cannot handle included stylesheets.
Nowadays I always use Saxon either through the command line, or you could write a small Java program to use it through the Java object in the data step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants