[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Help with elements nested at different levels

Subject: RE: Help with elements nested at different levels
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 31 Dec 2007 00:03:24 -0000
RE:  Help with elements nested at different levels
> I have written an xsl file that parses the individual 
> "Script" nodes in the ScriptCatalog and it works fine.... the 
> problem recently is that FileMaker has now added the ability 
> that the Script Element I am looking for in the ScriptCatalog 
> might be nested within a Group or SubGroup or any other sub 
> nesting ...

You haven't shown your current code, so it's hard to know where you are
starting from. 

If you use the "push" style of XSLT coding, using xsl:apply-templates and
template rules to do a rule-driven recursive traversal of the input tree,
then your code should need very little modification to cope with the fact
that Script elements can now appear in different places in the input. On the
other hand, if you use "pull" processing, where your code navigates
explicitly to the elements that need to be processed, then your code may
need a wholesale rewrite. This is exactly the reason why users are always
advised to use the "push" coding pattern whenever there is any chance that
the input tree structure may be unpredictable or variable.

Push processing is characterized by extensive use of xsl:apply-templates,
usually without a select attribute. Pull processing is characterized by
extensive use of xsl:for-each and xsl:call-template.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Vincenzo Menanno [mailto:enzo13@xxxxxxx] 
> Sent: 30 December 2007 22:12
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Help with elements nested at different levels
> 
> Hi everyone,
> 
> Pardon the lack of knowing the right terms and all...
> 
> I believe we are using xerces xml parser and we are using XSLT 2.0
> 
> Here is a very small collapsed sample of the XML I am dealing with...
> 
> <?xml version="1.0" encoding="UTF-16"?>
> <FMPReport link="Summary.xml" type="Report" version="9.0v3"  
> creationDate="12/30/2007" creationTime="3:56:20 AM">
>      <File name="sample.fp7" path="/Users/tony/Desktop">
> 
>          <ScriptCatalog>
>              <Script id="1" name="my script" includeInMenu="True"  
> runFullAccess="False">
>                  <StepList>
>                      ...
>                  </StepList>
>              </Script>
>              <Group id="2" name="New Group" includeInMenu="True"  
> groupCollapsed="False">
>                  <Script id="4" name="New Script" 
> includeInMenu="True"  
> runFullAccess="False">
>                      <StepList>
>                          ...
>                      </StepList>
>                  </Script>
>              </Group>
>              <Group id="5" name="sdfsd" includeInMenu="True"  
> groupCollapsed="False">
>                  <Group id="7" name="sfdkjhs" includeInMenu="True"  
> groupCollapsed="False">
>                      <Group id="9" name="jdfhgsdf"  
> includeInMenu="True" groupCollapsed="False">
>                          <Script id="17" name="fjsyfjsdfg"  
> includeInMenu="False" runFullAccess="False">
>                              ...
>                          </Script>
>                          <Script id="18" name="fksjhgfjhsg"  
> includeInMenu="False" runFullAccess="False">
>                              ...
>                          </Script>
>                          <Script id="19" name="dfgdfkjhg"  
> includeInMenu="False" runFullAccess="False">
>                              <StepList/>
>                          </Script>
>                      </Group>
>                  </Group>
>              </Group>
>              <Script id="11" name="sdfjhg" includeInMenu="True"  
> runFullAccess="False">
>                  <StepList/>
>              </Script>
>              <Script id="12" name="-" includeInMenu="True"  
> runFullAccess="False">
>                  <StepList/>
>              </Script>
>              <Group id="13" name="Hidden" includeInMenu="False"  
> groupCollapsed="True">
>                  <Group id="15" name="Hidden 1" 
> includeInMenu="False"  
> groupCollapsed="True"/>
>                  <Group id="20" name="Hidden 2" 
> includeInMenu="False"  
> groupCollapsed="True"/>
>              </Group>
>          </ScriptCatalog>
> 
>          <CustomMenuCatalog>
>              <CustomMenu id="1" name="FileMaker Pro Copy">
>                  <Options findMode="True" browseMode="True"  
> macPlatform="True"/>
>                  <BaseMenu name="FileMaker Pro" value="1"/>
>                  <MenuItemList>
>                      <MenuItem macPlatform="True" winPlatform="False">
>                          <Command id="57664" name="About 
> FileMaker Pro."/>
>                          <Step id="1" name="Perform Script"  
> enable="True">
>                              <StepText>Perform Script [ 
> "&lt;unknown&gt;" ]</StepText>
>                              <CurrentScript value="Pause"/>
>                              <Script id="0" name="&lt;unknown&gt;"/>
>                          </Step>
>                      </MenuItem>
>                      <MenuItem macPlatform="True" winPlatform="False">
>                          <Step id="1" name="Perform Script"  
> enable="True">
>                              <StepText>Perform Script [ 
> "&lt;unknown&gt;" ]</StepText>
>                              <CurrentScript value="Pause"/>
>                              <Script id="0" name="&lt;unknown&gt;"/>
>                          </Step>
>                      </MenuItem>
>                  </MenuItemList>
>              </CustomMenu>
>          </CustomMenuCatalog>
> 
>      </File>
> </FMPReport>
> 
> 
> ---------------------------
> 
> I have written an xsl file that parses the individual 
> "Script" nodes in the ScriptCatalog and it works fine.... the 
> problem recently is that FileMaker has now added the ability 
> that the Script Element I am looking for in the ScriptCatalog 
> might be nested within a Group or SubGroup or any other sub 
> nesting ...
> 
> Group/Group/Group/Script
> 
> Ken already emailed me a suggestion where I could just use 
> //Script to get all the script elements... but the problem 
> with that is the CustomMenuCatalog might also have MenuItems 
> with Script elements.
> 
> Originally I had this to get me all the script elements...
> 
> /FMPReport/File[1]/ScriptCatalog[1]/Script
> 
> But that now only gets me to the first Script if it is not 
> within a group.
> 
> This however picks up all the entries inside the CustomMenuCatalog
> 
> //Script
> 
> Any suggestions on how I can get the complete list of all the 
> Script entries even if they are nested 1, 2, 3, ...n levels?
> 
> Thanks
> 
> Vince

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.