IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: XLBob
About
User Name: XLBob
Forum Rank: Newbie
Real Name:
Location Sydney
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Tuesday, February 21, 2017
Last Visit: Wednesday, February 22, 2017 3:29:32 AM
Number of Posts: 2
[0.01% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: parse xml using xslt
Posted: Wednesday, February 22, 2017 3:29:32 AM
wow, it worked like magic. Thanks so much for your help.
Topic: parse xml using xslt
Posted: Tuesday, February 21, 2017 4:33:21 AM
I have a xml file as below. I tried to parse it using XSLT (Extensible Stylesheet Language Transformations). However the syntax may be incorrect as I can not retrieve any values out of xml file. please refer below for my xml file and xslt template I wrote. thanks for your help.
-------below is xml file----------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<DataProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/sqlserver/2008/DataDebugger/">
<ProfileVersion>1.0</ProfileVersion>
<DataSources>
<DtsDataSource ID="{AAE5E929-50B5-4A2B-8C9B-319A5E8DBB07}" Name="LocalHost.ers_s_stage_ADO_Connection">
<DtsConnectionManagerID>LocalHost.ers_s_stage_ADO_Connection</DtsConnectionManagerID>
</DtsDataSource>
<DtsDataSource ID="{9BEC2151-F307-4E3F-8643-705B4CA40369}" Name="Profiling_RGMS_ODF_CA_GM_INSTITUTIONS">
<DtsConnectionManagerID>Profiling_RGMS_ODF_CA_GM_INSTITUTIONS</DtsConnectionManagerID>
</DtsDataSource>
<DtsDataSource ID="{2E30D6F5-6D63-43C1-8FB3-6FEC8D3175A7}" Name="LocalHost ers_s_land">
<DtsConnectionManagerID>LocalHost ers_s_land</DtsConnectionManagerID>
</DtsDataSource>
</DataSources>
<DataProfileInput>
<ProfileMode>Exact</ProfileMode>
<Timeout>0</Timeout>
<Requests>
<ColumnNullRatioProfileRequest ID="NullRatioReq">
<DataSourceID>{AAE5E929-50B5-4A2B-8C9B-319A5E8DBB07}</DataSourceID>
<Table Schema="dbo" Table="RGMS_ODF_CA_GM_INSTITUTIONS" />
<Column IsWildCard="true" />
</ColumnNullRatioProfileRequest>
</Requests>
</DataProfileInput>
<DataProfileOutput>
<Profiles>
<ColumnNullRatioProfile ProfileRequestID="NullRatioReq" IsExact="true">
<DataSourceID>{AAE5E929-50B5-4A2B-8C9B-319A5E8DBB07}</DataSourceID>
<Table DataSource="." Database="ers_s_stage" Schema="dbo" Table="RGMS_ODF_CA_GM_INSTITUTIONS" RowCount="-1" />
<Column Name="ersIngestionDate" SqlDbType="DateTime" MaxLength="0" Precision="255" Scale="255" LCID="-1" CodePage="0" IsNullable="false" StringCompareOptions="0" />
<NullCount>0</NullCount>
</ColumnNullRatioProfile>



--Below is my xslt template----------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:text>DataSource;Table;ColumnName;RowCount;NullCount</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>

<xsl:for-each select="DataProfile/DataProfileOutput/Profiles/ColumnNullRatioProfile">
<xsl:text>"</xsl:text>
<xsl:value-of select="/Table/@Database"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="/Table/@Table"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="/Column/@Name"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="/Table/@RowCount"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="/Table/NullCount"/>
<xsl:text>"</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:for-each>

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

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.