SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to add attribute from Parent element to child element's attribute using visual studio designer


How to add attribute from Parent element to child element's attribute using visual studio designer

Author
Message
Balaji L
Balaji L
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1117 Visits: 271
Hi,
Can you please take a look on the attached XSD.

The requirement here is how to add the root element attribute to all its child element.

Consider the root Element : DB and its attribute : MAC,INM and DBNM. (Shown in the attached doc)

Need to refer these attribute to all its child element.
How to achieve this using visual studio designer (Any other workaround also fine for me).
I tried to add attribute by right click on the child element select " New attribute ". But this doesn't helped me. I am not sure how to reference the attribute from the parent to child elements.

Any help would be really appreciated.

Thanks,
Balaji L
Attachments
SampleXml.zip (22 views, 1.00 KB)
XSD_ScreenShot.doc (27 views, 123.00 KB)
LutzM
LutzM
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16715 Visits: 13559
Hi Balaji,

I'm wondering how the xsd shows up all of a sudden... since it looks almost like the issue we discussed just the other day within the following thread http://www.sqlservercentral.com/Forums/FindPost729749.aspx...

The question you're asking is not clear to me at all...
Wherein do you need to refer the root element? Are you looking for a table structure in SQL Server, another xml statement, a modified xsd, a PowerPoint document or anything else?
What is the final goal you're trying to achieve with both of your posts (this one and the one I mentioned above)?

Would you please post your required result including some description what you're really looking for in total? It would make much more sense than starting various posts with frictions of the problem you're struggling with...

Btw: The element "MAC" is not a child element of "DB" and as per the structure of the xsd all ther other elements already are child elements of "DB".

Edit: typo fixed



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Balaji L
Balaji L
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1117 Visits: 271
Lutz,

Element "DB" has attributes 'MNM','INM' and 'DBNM'. How do you make these as global attributes.

And "DB" element has its child element 'SOB,TBL,VW,CNST,etc..' I need all the child element should have the global attributes. How do you refer this.

So the child element SOB has additional 3 attributes like this 'OB,CNT,MNM,INM and DBNM'.
Likewise TBL has addtional 3 attributes along with TBL_Id,NM,OID,OWN,CDT,DB_Id.

I can easily import all the TBL attribute to table called 'xml_tbl'.

Please let me know if you have any question.

Thanks,
Balaji L


Attachments
Result.zip (11 views, 61.00 KB)
LutzM
LutzM
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16715 Visits: 13559
Your example shows the final result after importing the xml structure.
You don't really need the xsd for that...
So, the result set does not really have to do with the question you've asked. This expected result would have been much appreciated in the discussion earlier (see link above)...
If you'd need to include the DB name you just have to include in the select clause I posted in the link mentioned above.
But please be aware that the upload time will increase as already said in the post.

Another option would be to modify your xsd schemas so it already includes all the target tables and target column definition.
Then you could use the xsd for loading the xml file. For details on how to use xml data including usage of xml schema (if you have the option to do that) please read the XML workshop series by J. Sebastian (search for XML workshop on this site).



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Balaji L
Balaji L
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1117 Visits: 271
Lutz,

The result is achieved joining tables MAC,INST,DB,TBL. To avoid that I am looking to change the XSD. Declaring DB element attribute as global attribute. In that case I will get all the required column in a single attribute.

Seems to be its verys simple but not sure how to achieve this. ( how to declare one element attribute global and how to refer the global attribute in the child element)

Still I am searching answer for this. As suggested by you am going thru' online xml books.


Thanks,
Balaji L
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search