Re: XSLT: from 2 elements to 1

Discussion in 'XML' started by Will Stuyvesant, Jul 15, 2003.

  1. > [Dimitre Novatchev}
    > Sory, but there's no XML in your example.
    >
    > Can you provide the minimal possible example (xml source document
    > explained, the desired properties of the transformation, the exact
    > desired result) ?



    Just about the simplest example I can think of:

    According to the derivation rule

    P and P
    -------
    P

    I am looking for XSLT that transforms

    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <apply>
    <and/>
    <ci>P</ci> <!-- (1) -->
    <ci>P</ci> <!-- (2) -->
    </apply>
    </math>

    into:

    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <ci>P</ci>
    </math>

    The comments can be ignored.

    Note that the transformation should also work for more
    complicated MathML expressions than just <ci>P</ci>. If
    that is the case, the XSLT has to check whether the same
    XML tree is in positions (1) and (2).

    Perhaps XSLT is just not suitable for these kind of
    templated transformations. But somewhere on usenet I read
    that XSLT "constains a theorem prover in itself" so I
    thought perhaps we can reuse that.
    Will Stuyvesant, Jul 15, 2003
    #1
    1. Advertising

  2. "Will Stuyvesant" <> wrote in message
    news:...
    > > > [Will]
    > > > Just about the simplest example I can think of:
    > > >
    > > > According to the derivation rule
    > > >
    > > > P and P
    > > > -------
    > > > P

    > >
    > > [Dimitre Novatchev]
    > > And how will you represent in xml the above rule?
    > >
    > > This is not nit-picking, but very important question -- very much

    depends on
    > > its answer. Hint: you must somehow specify that the two arguments of

    "and"
    > > are identical.
    > >

    >
    > Indeed this is a core part of the problem. I don't know how to
    > represent this derivation rule in XSLT, that is why I started this
    > thread!


    Not in XSLT -- you do not know how to represent the rule in XML. XSLT is
    XML.

    Therefore this is not (yet) an XSLT problem. XSLT starts when given the
    source xml (or an equivalent tree) and the description of the properties of
    the transformation.

    I have some ideas about a possible transformation, but they can be
    implemented only after you propose an XML representation of the rule.


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL



    >
    > We are now looking at another solution, representing the above rule in
    > an extended MathML and using a tool we are developing. We need to
    > bind attribute values and tag names to tool program variables, and be
    > able to use these variables for matching and output. This way an XML
    > tree can be created that can be matched with the input. But a lot of
    > work has still to be done. To get an idea how the rule is represented
    > in XML:
    >
    > <rule>
    > <antecedent>
    > <ws-tree bind="A"/>
    > <apply>
    > <and/>
    > <ws-tree bind="B"/>
    > <ws-tree use="B"/>
    > </apply>
    > <ws-tree bind="C"/>
    > </antecedent>
    > <consequence>
    > <ws-tree use="A"/>
    > <ws-tree use="B"/>
    > <ws-tree use="C"/>
    > </consequence>
    > </rule>
    >
    >
    > The elements "rule", "antecedent", "consequence" and "ws-tree" are an
    > extension to MathML.
    >
    > The tool applying this rule to the input (in an earlier post), tries
    > to match the input with the antecedent of the rule. When the tool
    > sees a "ws-tree" element with a bind attribute, it binds the element
    > at that point in the input to a variable in program memory that takes
    > as name the value of attribute "bind". When there is a ws-tree with a
    > "use" attribute the tool checks whether the input indeed has that tree
    > at that position in the input.
    >
    > If the input matches then the XML output can be created according to
    > the consequence of the rule.
    >
    > There will be more elements like "ws-tree" needed, this is still
    > research.
    Dimitre Novatchev, Jul 16, 2003
    #2
    1. Advertising

  3. "Will Stuyvesant" <> wrote in message
    news:...
    > [Dimitre Novatchev]
    > > Therefore this is not (yet) an XSLT problem. XSLT starts when given the
    > > source xml (or an equivalent tree) and the description of the properties

    of
    > > the transformation.
    > >
    > > I have some ideas about a possible transformation, but they can be
    > > implemented only after you propose an XML representation of the rule.

    >
    > But, in the original post there is an example and later I also added a
    > rule encoded in XML (used by a template mechanism different from
    > XSLT). As shown, in the simplest case only the elements <rule>,
    > <antecedent> (rule input) and <consequence> (rule output) are needed.
    > The rule itself should also be clear, if you have ever seen derivation
    > rules in logic or mathematics, and even if you did not, you can
    > imagine all the kind of rules that could be useful. What else do you
    > need??


    There must be something expressing the important property that the two
    arguments of "and" are equal (identical) and that this should be regarded as
    important by the problem solver. This generally cannot be inferrred
    automatically.

    >
    > Perhaps you can answer this one:
    >
    > How can I transform
    >
    > <container>
    > <item number="1"/>
    > <item number="1"/>
    > </container>
    >
    > to
    >
    > <item number="1"/>
    >
    > ?
    >
    > That would be
    >
    > <xsl:template match="?????">
    > <item number="1"/>
    > </xsl:template>


    Yes, but it will not work in the general case:

    <xsl:template match="container[*[1][self::item and @number="1"]
    and
    *[2][self::item and
    @number="1"]
    and
    not(*[3])
    ]">
    <item number="1"/>
    </xsl:template>



    >
    > so the problem is the ????? And I can't find this in the (XPath)
    > docs.
    >
    > I did some stuff with XSLT but I have no idea how to do something like
    > "remember a subtree in a variable" and then later matching against it.


    If the rule can express the essential properties, the transformation will
    not be too problematic.


    Another question is when the inference process will eventually stop? All the
    rules can be tried and applied on the result, then on the next result, and
    so on... potentially never stopping. There must be some rules about this as
    well.


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL
    Dimitre Novatchev, Jul 17, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    635
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,658
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    610
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    705
    Henry S. Thompson
    Oct 19, 2005
  5. Gerald Aichholzer
    Replies:
    2
    Views:
    2,480
    Gerald Aichholzer
    Jun 27, 2006
Loading...

Share This Page