Subject: [xsl] Re: key() question? From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Wed, 10 Jul 2002 03:11:34 -0700 (PDT) |
--- Steven Noels <stevenn at outerthought dot org> wrote: > > Hi all, > > I'm trying to wrap my brains across a problem which I assume I must > be > solving using nasty key() tricks. > > Here's how my input file looks like: > > <contentModel ename="document"> > <group> > <element name="header"/> > <separator type=","/> > <element name="body"/> > <separator type=","/> > <element name="footer"/> > <occurrence type="?"/> > </group> > </contentModel> > <attlist ename="document"> > <attributeDecl aname="id" ename="document" atype="ID"/> > <attributeDecl aname="xml:lang" ename="document" atype="NMTOKEN"/> > </attlist> > <contentModel ename="header"> > <group> > <element name="title"/> > <separator type=","/> > <element name="subtitle"/> > <occurrence type="?"/> > <separator type=","/> > <element name="version"/> > <occurrence type="?"/> > <separator type=","/> > <element name="type"/> > <occurrence type="?"/> > <separator type=","/> > <element name="authors"/> > <occurrence type="?"/> > <separator type=","/> > <element name="notice"/> > <occurrence type="*"/> > <separator type=","/> > <element name="abstract"/> > <occurrence type="?"/> > </group> > </contentModel> > <attlist ename="header"> > <attributeDecl aname="id" ename="header" atype="ID"/> > <attributeDecl aname="xml:lang" ename="header" atype="NMTOKEN"/> > </attlist> > > and much more like this, so in essence I have plenty of > <contentModel> > and <attlist> elements which contain content model defitions composed > of <element>s, <group>s and the like. Think DTDs but in an XML > syntax. > > I have some keys declared for easy access to the attributes declared > for a specific element, and to retrieve the contentModels in which an > element is referred to: > > <xsl:key name="attlistbyname" match="/dtd/attlist" use="@ename"/> > <xsl:key name="contentmodelbychildren" match="//contentModel" > use="descendant::element/@name"/> > > The problem with DTDs without an accompagnying instance is that you > are > not able to devise which element is the root element. As a rule of > thumb in my situation, I define root elements as <contentModel> > elements which have no <element> counterpart, i.e. the 'document' > contentModel in this case: you find a <contentModel ename="document"> > without an <element name="document"/> that refers to it inside some > other <contentModel>. > > My question is how I can easily locate <contentModel> elements which > don't have an <element> counterpart bearing an attribute 'name' with > the contentModel/@ename as its value. > > Anyone an idea? > Hi Steve, To find all such contentModel, use the following XPath expression: /dtd/contentModel[not(@ename = /dtd/contentModel/group/element/@name)] Cheers, Dimitre Novatchev. __________________________________________________ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] key() question?, TSchutzerWeissmann | Thread | [xsl] Numbering, alexandre bord |
Re: [xsl] key() question?, Jeni Tennison | Date | RE: [xsl] Design Issues in XSLT, WATKIN-JONES,ADAM (H |
Month |