Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reuse of Attributed Elements to make list?

Status
Not open for further replies.

matrix01011

Technical User
Jun 19, 2013
3
US
Fellow forum Members, the code below is an example of how S1000D XML handles ancronyms:

<acronym acronymtype="at01"> <acronymTerm>NASA</acronymTerm> <acronymDefinition id="acr-0001">National Aeronautics and Space Administration</acronymDefinition> </acronym>

My objective is to figure out what XML code functions as a lasso that retrieves the attribute acronymtype="at01" found within a lot of data modules and collects all of this attributed acronym element data in one common data module I'm calling "List Of Acronyms".


In other words, what XML mechanism should I be looking at if I want to reuse attributed data residing within many data modules and have it automatically gathered and reused in one common data module? I want to avoid the work of manually gathering all of the different acronyms residing within many data modules and building an acronym list manually. My goal is for my Acronym List to auto generate. Is this possible with Issue 4.01 of the S1000D schema? Any hints, help, tips greatly appreciated. Thanks in advance.
 
You did not specify the operating environment in which all this data are swimming, so some generalities.

My first cut at gathering this information, assuming that all the XML documents are in a directory structure that is addressable, would be to use a scripting language to assemble an XML 'document of documents' and then use XSLT to process that document, using the XSLT document() function to extract all the useful nodes. Given my skill level, I would have it done in about 30 minutes. As someone new to XML, you have a bit of a learning curve.

I have to get busy on the day job right now, but have a look at the XSLT and XPath tutorials on I will check back to see what progress you have made...

Tom Morrison
Hill Country Software
 
Tom,
Thanks for your reply. I am using a suite called Arbortext S1000D for Aerospace & Defense. It's made by PTC which is the same software company behind ProEngineer now called CREO. This suite is comprised of six main applications. The only apps I'm using from this suite are Arbortext, the Common Source Data Base (CSDB) module, and the Publisher Module. So to answer your question, all my data is swimming inside a CSDB.

You mention using a scripting language together with XLink might be the solution. However, I'm scratching my head how a script can be implemented either within the CSDB module or the Publisher module that will lasso all the data and populate my List of Acronyms Data Module. All the data modules are swimming within a CSDB and getting a script to run within the CSDB is where I see a potential problem. Thanks for the link. I have absorbing the XLink material and trying to figure out how it fits to what I want to do. Again thanks for the help.
 
I had a look at the web site for the authoring/content management system you cited. Is my conjecture that it works on Windows. Correct?

Does the thing that looks like a database actually a directory structure containing all of the XML source artifacts? Or is the database storing the XML in a relational database?

In any event, what you need to be able to do is get all the XML documents that contain the acronyms into separate files, one XML document/file.

Then make an XML document (let's call it filelist.xml) that has the structure:
XML:
<files>
<file>path/to/file1.xml</file>
<file>path/to/file2.xml</file>
</files>

Of course, I am presuming this file will contain dozens, hundreds (?), of <file> entries. This document becomes the input document for the following XSLT stylesheet.

Then, you would create an XSLT along the following general lines. (Warning, this is typed in without any testing.)

Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output indent="yes"/>

<xsl:template match="/">
    <acronymn-collection>
        <xsl:apply-templates select="files/file"/>
    </acronymn-collection>
</xsl:template>

<xsl:template match="files/file">
    <xsl:comment> Pulling from <xsl:value-of select="."/> </xsl:comment>
    <xsl:copy-of select="document(.)//acronym"/>
    <xsl:comment> End of <xsl:value-of select="."/> </xsl:comment>
</xsl:template>

</xsl:stylesheet>

This code simply copies all the <acronym> subtrees that it finds into the output without restructuring the subtree.

Ask questions... One possible minor complication is the use of XML namespaces in your documents. In a complex authoring system, I would suspect that, at a minimum, a default namespace is declared at or near the top of the XML document.

Tom Morrison
Hill Country Software
 
My objective is to figure out what XML code functions as a lasso that retrieves the attribute [highlight #FCE94F]acronymtype="at01"[/highlight] found within a lot of data modules and collects all of this attributed acronym element data in one common data module I'm calling "List Of Acronyms".

I missed the subtlety of wanting only acronyms of a specific type. This changes one line in the XSLT, adding an XPath predicate so that only <acronym> nodes that have that specific acronymtype value are select for copying..

Code:
<xsl:copy-of select="document(.)//acronym[highlight #FCE94F][@acronymtype='at01'][/highlight]"/>


Tom Morrison
Hill Country Software
 
Tom,
Thank you very much for your posting. This weekend I am making plans to sit in front of my computer and experiment with the code you have provided and what I have learned from Again thank you very much for your postings.
 
Dear matrix01011,

Any progress?

Tom Morrison
Hill Country Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top