XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 27 Feb 2012 10:57 AM
So basically I have Source and Target XML.

The gist of it is that I need to get the data on the target XML so that

H | W | L
1 | 2 | 3
4 | 5 | 6
7 | 8 | 9

I can't pinpoint whether the issue is with the Source XML or the XSLT

In the Target XML, I the <Values> in <AttributeCollections> Grouped based on the <attribute> tags above.


UnknownClienteeee.xml
source xml

UnknownClienteeee.xsd
Source XSD

UnknownUntitled13.xsl
XSL I have atm

UnknownClientFeaturesImportMaster.xml
Target XML

Postnext
Ivan PedruzziSubject: grouping a group?
Author: Ivan Pedruzzi
Date: 27 Feb 2012 02:36 PM

I am sure I can follow, could you post an XML document that shows the desired result, given as input Clienteeee.xml?

Ivan Pedruzzi
Stylus Studio Team

Postnext
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 27 Feb 2012 03:19 PM
Originally Posted: 27 Feb 2012 03:06 PM
i'm working on massaging the xml to the desired output, here is a screencap for now

Just to add the complexity, Each MultiDimension can have a different number of Attributes vs Values.

In the screen it's like a 4 x 4 grid, but the next set can be a 3x3 grid or a 6x7 grid


Image2-27-20123-02-53PM.jpg
screenshot

Postnext
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 27 Feb 2012 03:39 PM
<MultiDimension>
<Name>Posters</Name>
<Profiles>
<Profile>
<ProfileName>Fixtures</ProfileName>
</Profile>
</Profiles>
<Attributes>
<Attribute>
<Name>Height</Name>
<DataType>AlphaNumeric</DataType>
</Attribute>
<Attribute>
<Name>Width</Name>
<DataType>AlphaNumeric</DataType>
</Attribute>
<Attribute>
<Name>Type</Name>
<DataType>AlphaNumeric</DataType>
</Attribute>
<Attribute>
<Name>Language</Name>
<DataType>AlphaNumeric</DataType>
</Attribute>
</Attributes>
<AttributeCollections>
<AttributeCollection>
<Value>25</Value>
<Value>55</Value>
<Value>Ambassador Station &amp; ASC's</Value>
<Value>English</Value>
</AttributeCollection>
<AttributeCollection>
<Value>25</Value>
<Value>55</Value>
<Value>Banking Wall, Brochure Wall &amp; Waiting Area Wall</Value>
<Value>English</Value>
</AttributeCollection>
<AttributeCollection>
<Value>25</Value>
<Value>55</Value>
<Value>Imperial Service Flagship Poster Posts</Value>
<Value>English</Value>
</AttributeCollection>
<AttributeCollection>
<Value>25</Value>
<Value>55</Value>
<Value>Retail Flagship Poster Posts</Value>
<Value>English</Value>
</AttributeCollection>
<AttributeCollection>
<Value>44</Value>
<Value>19</Value>
<Value>Imperial Service Flagship Poster Posts</Value>
<Value>English</Value>
</AttributeCollection>
<AttributeCollection>
<Value>44</Value>
<Value>19</Value>
<Value>Retail Flagship Poster Posts</Value>
<Value>English</Value>
</AttributeCollection>
</AttributeCollections>
</MultiDimension>

Postnext
Ivan PedruzziSubject: grouping a group?
Author: Ivan Pedruzzi
Date: 27 Feb 2012 04:28 PM

It seems like there is no way to correlate AttributeCollection to Attribute. The attached solution uses the number of Attribute to group the AttributeCollection elements.

Does it help?

Ivan Pedruzzi
Stylus Studio Team


DocumentUntitled13_grouped.xsl

Postnext
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 27 Feb 2012 04:58 PM
>
>It seems like there is no way
>to correlate
>AttributeCollection to
>Attribute. The attached
>solution uses the number of
>Attribute to group the
>AttributeCollection elements.
>
>Does it help?
>
>Ivan Pedruzzi
>Stylus Studio Team

It's helping a bit. Certainly has given me more ideas. Let me play around with your XSL that you have given me.

Thanks for the help so far!

Postnext
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 28 Feb 2012 04:38 PM
I couldn't get exactly what I wanted, so I rejigged the source from Access and changed the way i'm structuring the data.

now I have an issue with apply templates. This is what I have in the XSL:

<AttributeCollections>
<xsl:for-each select="AttributeCollection">
<AttributeCollection>
<Value>
<xsl:apply-templates select="Value1"/>
</Value>
<Value>
<xsl:apply-templates select="Value2"/>
</Value>
<Value>
<xsl:apply-templates select="Value3"/>
</Value>
<Value>
<xsl:apply-templates select="Value4"/>
</Value>
</AttributeCollection>
</xsl:for-each>
</AttributeCollections>

Where I find Value[x] and just take the value and template it to <value> on the target

is there a way to have a If/For clause to check that if the source has a tag that exists, apply template.. and if it doesn't, then skip?

Postnext
Ivan PedruzziSubject: grouping a group?
Author: Ivan Pedruzzi
Date: 28 Feb 2012 05:11 PM

Move the <Value> wrapper inside your template, if the value is not present in the input, it doesn't match the rule

<AttributeCollection>
<xsl:apply-templates select="Value1|Value2|Value3|Value4"/>
</AttributeCollection>

....

<xsl:template match="Value1|Value2|Value3|Value4">
<Value>
<xsl:value-of select="."/>
</Value>
</xsl:template>

Ivan Pedruzzi
Stylus Studio Team

Postnext
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 28 Feb 2012 07:14 PM
>
>Move the <Value> wrapper
>inside your template, if the
>value is not present in the
>input, it doesn't match the
>rule
>
><AttributeCollection>
><xsl:apply-templates
>select="Value1|Value2|Value3|V
>alue4"/>
></AttributeCollection>
>
>....
>
><xsl:template
>match="Value1|Value2|Value3|Va
>lue4">
><Value>
><xsl:value-of
>select="."/>
></Value>
></xsl:template>
>
>Ivan Pedruzzi
>Stylus Studio Team


I'm guessing from the answer that there is no way to specify a wildcard or to have say Value1-99 or something like that, correct?

Postnext
Ivan PedruzziSubject: grouping a group?
Author: Ivan Pedruzzi
Date: 28 Feb 2012 09:02 PM
apply-templates select="*" for matching any element.

A More sophisticate technique could filter in only those with a name that starts with a prefix

apply-templates select=*[starts-with(local-name(),'Value')]

Ivan Pedruzzi
Stylus Studio Team

Posttop
Glory LeungSubject: grouping a group?
Author: Glory Leung
Date: 28 Feb 2012 10:01 PM
>
>Move the <Value> wrapper
>inside your template, if the
>value is not present in the
>input, it doesn't match the
>rule
>
><AttributeCollection>
><xsl:apply-templates
>select="Value1|Value2|Value3|V
>alue4"/>
></AttributeCollection>
>
>....
>
><xsl:template
>match="Value1|Value2|Value3|Va
>lue4">
><Value>
><xsl:value-of
>select="."/>
></Value>
></xsl:template>
>
>Ivan Pedruzzi
>Stylus Studio Team


I'm guessing from the answer that there is no way to specify a wildcard or to have say Value1-99 or something like that, correct?

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.