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

  • 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

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • 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

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • 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

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply