473,586 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:typedNam e="ID" />
<xs:element name="column_2" msdata:ReadOnly ="true" minOccurs="0" type="xs:int" msprop:typedNam e="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="DsStoredPro c" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DsStoredP roc" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<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 4289
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 misunderstandin g, 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:typedNam e="ID" />
<xs:element name="column_2" msdata:ReadOnly ="true" minOccurs="0" type="xs:int" msprop:typedNam e="Name" />


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

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msprop="m sprop namespace">
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xs:eleme nt[@name='column_1 ']">
<xsl:copy>
<xsl:attribut e name="msprop:ty pedName">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!P LEASEtkachenko. 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:typedNam e="ID" />
<xs:element name="column_2" msdata:ReadOnly ="true" minOccurs="0" type="xs:int" msprop:typedNam e="Name" />


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

<xsl:styleshee t version="1.0"
xmlns:xsl="htt p://www.w3.org/1999/XSL/Transform"
xmlns:xs="http ://www.w3.org/2001/XMLSchema" xmlns:msprop="m sprop namespace">
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xs:eleme nt[@name='column_1 ']">
<xsl:copy>
<xsl:attribut e name="msprop:ty pedName">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
3981
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( Pk_myPrimaryKey INTEGER CONSTRAINT pk PRIMARY KEY DESCRIPTION 'This is the primary key of the table',
1
1669
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 <input> control is empty) or it is. I have tryed with the following: if( filMyFile.PostedFile != null) //HtmlInputFile filMyFile; { code
6
2399
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 = "frmMySearchWebForm.aspx?DOBDate=" + txtDOBDt popUp =window.open(QueryString,null, "height=50,width=80,status=no,left =0,top =0,toolbar=no,menubar=no,location=no,scrollbars...
1
1631
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 memory and then reset. As this happens several times over the course of an 8 hour stress run, I'm looking for a solution. The xslt file has the...
3
2744
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: <DOCUMENT> ...... ...... some lead elements ...... <SEGMENT_LIST>
1
2600
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 elements/attributes etc. defined but the values in these elements/attributes might be blank or incorrect, as two examples below: <?xml version="1.0"...
2
2563
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 elements/attributes etc. defined but the values in these elements/attributes might be blank or place holders, as two examples below: Example - File type 1
3
3340
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 path="c:/temp/module_m34_blabla.tmp"/> ... <moduleAddition path="c:/temp/moduleaddition_m17.tmp"/>
0
4916
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 previous page 2. If RDP is opened in fullscreen mode, then onconnected, i want to go back to previous page.
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.