Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to add attribute from Parent element to child element's attribute using visual studio designer Expand / Collapse
Author
Message
Posted Wednesday, June 10, 2009 7:23 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, July 24, 2013 3:13 AM
Points: 853, 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


  Post Attachments 
SampleXml.zip (4 views, 1.04 KB)
XSD_ScreenShot.doc (19 views, 123.50 KB)
Post #732251
Posted Wednesday, June 10, 2009 12:57 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 3:13 PM
Points: 6,842, Visits: 13,364
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
Post #732565
Posted Wednesday, June 10, 2009 11:11 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, July 24, 2013 3:13 AM
Points: 853, 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



  Post Attachments 
Result.zip (3 views, 61.47 KB)
Post #732752
Posted Thursday, June 11, 2009 4:00 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 3:13 PM
Points: 6,842, Visits: 13,364
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
Post #732872
Posted Thursday, June 11, 2009 4:16 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, July 24, 2013 3:13 AM
Points: 853, 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
Post #732882
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse