#33246 - 09/08/10 12:45 PM
metadata group and document creation help
|
OL Expert
Registered: 04/01/03
Posts: 236
Loc: Lincoln, NE
|
I'm attempting a presstalk script to create metadata fields and hierarchy. The data coming in can have 1 to n number of records that I want to create metadata for. My desired metadata result is each record have its own set of child nodes like this:
<client>
<address>
<clientid>
<purchase>
</client>
<client>
<address>
<clientid>
<purchase>
</client>
With definemeta it appears I can't create parent and child nodes. I think, though, that the group or document would fit nicely as my parent node. I've tried using the document and group metadata functions, but can't get them to create multiple groups or documents. All fields just end up in either the root group or document. Here are some variations I've tried. To test the code, I'm using the "Refresh Metadata" option inside of Designer. (Note that I am not changing the data in the variables to keep it simple...)
for(¤t.line,0,1,10)
begindocument()
definemeta('ClientAddress',&ClientAddress,2, 'Job.Group.Document')
definemeta('ClientID',&ClientID,2, 'Job.Group.Document')
enddocument()
endfor()
But the above generates only the root metadata document and puts all nodes in it. OK, that makes some sense, I think it's because it needs the document index [] on it. So then I tried:
for(¤t.line,0,1,10)
begindocument()
definemeta('ClientAddress',&ClientAddress,2, 'Job.Group.Document['+inttostr(¤t.line)+']')
definemeta('ClientID',&ClientID,2, 'Job.Group.Document['+inttostr(¤t.line)+']')
enddocument()
endfor()
By adding the index based upon the loop variable I'd have it, but it still only generates one root metadata document and now places all the nodes in the metadata group above the document. Lastly I tried hard coding a sample see if I could get it to create multiple metadata documents:
begindocument()
definemeta('ClientAddress','test1',2, 'Job.Group.Document[0]')
definemeta('ClientID','111',2, 'Job.Group.Document[0]')
enddocument()
begindocument()
definemeta('ClientAddress','test2',2, 'Job.Group.Document[1]')
definemeta('ClientID','222',2, 'Job.Group.Document[1]')
enddocument()
But it still only creates the one root metadata document. I also tried the above sample with the begingroup function, but got essentially the same result. It never created more than one group. So what am I missing about creating metadata groups and documents in presstalk? Thanks! -nth-
|
Top
|
|
|
|
#33247 - 09/08/10 01:32 PM
Re: metadata group and document creation help
[Re: -nth-]
|
Benoit Potvin
Unregistered
|
nth,
If one 'record' equals one datapage, then you can set PlanetPress Design to create a structure where a 'metadata document' corresponds to one datapage. To do this:
1. Double click on the PlanetPress Design document root node and select the 'metadata' tab 2. In the 'Document Marker' section, just select 'Begin' as the marker and leave the condition blank. 3. Close the properties window and refresh metadata. 4. Open the data selector and switch to the metadata tab to validate that as many 'metadata' documents were created as there are datapages.
By proceeding this way, it makes it much easier to create metadata fields at the document level. To create a metadata field at the metadata-document level (like the customer ID), you just need to :
1. Select the data you want to add as metadata from the data pane. 2. Drag and drop your selection over the 'Metadata Fields' folder from the document structure. 3. Double-click on the created Metadata field and specify: - PlanetPress Talk ID/metadata field name - Level = Choose 'Document' to create the field at the metadata-document level. - Fields: ---Value = the data selection you have made from the data pane. ---Condition = leave blank if the data selection should apply to all metadata fields of this name ---Create action= Replace the value (i.e. if the field already exist for the current metadata document, overwrite its value with the specified data selection) 4. Close the properties box, refresh the metadata then validate with the data/metadata selector.
As I understand from your post, you are trying to define metadata from within a PlanetPress Talk object. When doing so, please note that either begindocument() or enddocument() should be used, but not both at the same time. Unless you are forced to work this way, I would advise to first try the user-interface method described above.
Also, from a metadata point of view, a single 'datapage' should not be part of several metadata-documents because of the inherent structure of the metadata, which is like a tree: one leaf can not be part of 2 branches. The same goes for datapages and metadata documents: one datapage should not be part of several metadata documents. If a single datapage should yield several metadata documents, you might want to try to modify the emulation parameters so that a datapage cannot contain more than 1 metadata-document (for example, if each line of the datapage should correspond to one metadata document, try instead to configure your emulation so that it contains only one line per page).
Hope this helps!
Ben
NB. I assume your PlanetPress Design document's emulation is not user-defined.
|
Top
|
|
|
|
#33249 - 09/08/10 02:29 PM
Re: metadata group and document creation help
[Re: ]
|
OL Expert
Registered: 04/01/03
Posts: 236
Loc: Lincoln, NE
|
One record doesn't equal one datapage. Often there will only be one datapage, but I'll need n number of metadata documents based upon page content.
Essentially I want to take advantage of the fact metadata creates a nice xml structure that I can use in a downstream Watch process. The document won't be used to print physical pages, just metadata info.
The nature of the data (line printer) is such that I need use presstalk to zero in on the portion of the data that contains the metadata fields. So I don't think I can tweak the emulation settings to get to the one datapage equals one metadata document scenario.
The main goal is to create the n number of parent/child xml nodes from each datapage.
It's using metadata outside of its intended purpose, I know, but I was hoping it would work.
I think I'll look at using the Execscriptfile presstalk function to create a simple xml file with the fields I need. Or just see how well I can extract the needed fields directly in a Watch script task.
I'll post my solution if I find one.
Thanks for the clarification on the metadata documents. -nth-
|
Top
|
|
|
|
#33250 - 09/08/10 04:48 PM
Re: metadata group and document creation help
[Re: -nth-]
|
OL Expert
Registered: 04/01/03
Posts: 236
Loc: Lincoln, NE
|
I ended up solving the issue by using vbscript (in a Watch task) to create a simple xml file containing the hierarchy I needed. Given that presstalk is similar in structure to vbscript, it was fairly straight forward to port the logic I'd already figured out.
BTW, good to see the forum has been upgraded! Any chance of getting RSS turned on for it?
-nth-
Edited by -nth- (09/08/10 04:48 PM)
|
Top
|
|
|
|
|
|