473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using XSLT to Append Attributes to an XSD File

I wrote an application to scrape a database and create an XSD file which will be annotated
by a map file in order to create a Typed DataSet. I was wondering if I could do the annotation
using XSLT.

Here is background on Typed DataSet:
Using Annotations with a Typed DataSet
http://msdn.microsoft.com/library/de...pedDataSet.asp

I need to append an attribute a specific XML node.

Change
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
to
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" msprop:typedName="ID" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" msprop:typedName="Name" />
I have included an XSD file that was returned as a result of my application before it is annotated.

Any thoughts would be appreciated.

Cheers,
Dave

================================================== =======

<?xml version="1.0" standalone="yes"?>
<xs:schema id="DsStoredProc" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DsStoredProc" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
<xs:element name="column_3" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
<xs:element name="column_4" msdata:ReadOnly="true" minOccurs="0" type="xs:short" />
<xs:element name="column_5" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
<xs:element name="column_6" msdata:ReadOnly="true" minOccurs="0" type="xs:short" />
<xs:element name="column_7" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="column_8" minOccurs="0" type="xs:short" />
<xs:element name="column_9" minOccurs="0" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:sequence>
<xs:element name="column_10" type="xs:int" />
<xs:element name="column_11" type="xs:short" />
<xs:element name="column_12" type="xs:int" />
<xs:element name="column_13" type="xs:short" />
<xs:element name="column_14" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Nov 12 '05 #1
3 4265
Hi David,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add annotation to your
typed dataset schema. If there is any misunderstanding, please feel free to
let me know.

As far as I know, the annotation is added to the .XSD files directly. So I
think we needn't use any programs to add them automatically. Although we
can use an XSLT to add, I think it will be more easier to add the
annotations manually to the schema.

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #2
David Elliott wrote:
I wrote an application to scrape a database and create an XSD file which will be annotated
by a map file in order to create a Typed DataSet. I was wondering if I could do the annotation
using XSLT.

Here is background on Typed DataSet:
Using Annotations with a Typed DataSet
http://msdn.microsoft.com/library/de...pedDataSet.asp

I need to append an attribute a specific XML node.

Change
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
to
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" msprop:typedName="ID" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" msprop:typedName="Name" />


That's piece of cake in XSLT, here is the idea:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msprop="msprop namespace">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xs:element[@name='column_1']">
<xsl:copy>
<xsl:attribute name="msprop:typedName">ID</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3
Thanks.

Dave
On Tue, 13 Jul 2004 14:47:46 +0200, "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote:
David Elliott wrote:
I wrote an application to scrape a database and create an XSD file which will be annotated
by a map file in order to create a Typed DataSet. I was wondering if I could do the annotation
using XSLT.

Here is background on Typed DataSet:
Using Annotations with a Typed DataSet
http://msdn.microsoft.com/library/de...pedDataSet.asp

I need to append an attribute a specific XML node.

Change
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" />
to
<xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" msprop:typedName="ID" />
<xs:element name="column_2" msdata:ReadOnly="true" minOccurs="0" type="xs:int" msprop:typedName="Name" />


That's piece of cake in XSLT, here is the idea:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msprop="msprop namespace">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xs:element[@name='column_1']">
<xsl:copy>
<xsl:attribute name="msprop:typedName">ID</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
1
by: Viktor Popov | last post by:
Hi, I'm trying to upload a file and I do that with this code, but there is a thing which doesn't work. I can't understand how to check if it isn't written the path to the file(the text field of...
6
by: Shashi | last post by:
I have developed ASP.Net application using .Net 1.1 Framework. When the user clicks image file through Java script I am using my search window as below. QueryString =...
1
by: John Moore | last post by:
I have a set of code that is called on every page load that loads an xslt file. The xslt file has an embedded <script> tag. Loading the page mutliple times causes aspnet_wp.exe to use all available...
3
by: R. P. | last post by:
Subject: XSLT to transform a flat XML file into a structured text file I have an XML file that lists the PDF file segment names and titles of a larger document and looks something like this: ...
1
by: Bilal Bhutta | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all...
2
by: Bilal | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all...
3
by: =?iso-8859-1?q?Christian_R=FChl?= | last post by:
Hi folks! I have a little noob problem here with XSLT. I have a XML file that looks like this: <archiveFiles> <module path="c:/temp/module_m17_blabla.tmp"/> <module...
0
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I want to call RDP on Page load and it is working fine.My code is in C#. But I am unable to perform following functions 1. when i disconnected from RDP, i want to go back to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.