Feature Request: WriteXml() Schema Change

Posts   
 
    
KPat
User
Posts: 15
Joined: 26-Mar-2004
# Posted on: 21-Dec-2004 18:13:41   

Otis,

I'm currently trying to run the xml generated via WriteXml() through an Xsl transform before sending it to the client (and vice versa from client -> server). Ideally, I'd like to have a single Xsl transform for entity out and a single Xsl transform for entity in. However, a small feature of the schema is blocking me at the moment. The problem is that the primary key field of each entity is specified by name as the first attribute of each Entity node.


<?xml version="1.0" encoding="utf-8" ?>
<Entity UID="1" Assembly="..."

Because the PK field is listed by name as an attribute, there doesn't appear to be a way to generically handle the data. Is there any way to change the schema to something a little more amenible to transforms? The following structure would work:


<?xml version="1.0" encoding="utf-8" ?>
<Entity Assembly="..."
     <PrimaryKeys>
          <Key Name="UID" Value="x"/>
          ...composite keys here...
     </PrimaryKeys>

Alternatively, do you know of a way to grab the first attribute of a node? I know this is not safe as some parsers will re-order the attributes but it would work as a temporary workaround.

Thanks, Kilby

KPat
User
Posts: 15
Joined: 26-Mar-2004
# Posted on: 21-Dec-2004 22:32:31   

I've found an alternate solution that I'll post for anyone else who runs into this. It is possible to copy all of the attributes from one arbitrary node to another without specifying any details about the attributes being copied. This works for me since I want all attributes. The syntax of the Xsl is as follows:


<xsl:template match="Entity">
     <Entity>
    <!-- Copy all attributes into entity node-->
    <xsl:copy-of select="@*" />
        
    <xsl:apply-templates select="Fields"/>

    <Collections>
        <xsl:apply-templates select="EntityCollectionReference"/>
    </Collections>
     </Entity>
</xsl:template>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Dec-2004 09:55:52   

Thanks for sharing, KPat! simple_smile

The Xml is abit verbose, in spring 2005 a move to a more XSchema + xml approach will be taken which should make the xml much easier to handle.

Frans Bouma | Lead developer LLBLGen Pro