xsl-list
[Top] [All Lists]

RE: [xsl] Help with elements nested at different levels

2007-12-30 17:04:56
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(_at_)mac(_dot_)com] 
Sent: 30 December 2007 22:12
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>