Many early Church writers interpret the sword as Mary's sorrows, especially as she saw Jesus die on the cross. Thus, the two passages are brought together as prediction and fulfillment.
St. Ambrose (December7) in particular sees Mary as a sorrowful yet powerful figure at the cross. Mary stood fearlessly at the cross while others fled. Mary looked on her Son's wounds with pity, but saw in them the salvation of the world. As Jesus hung on the cross, Mary did not fear to be killed but offered herself to her persecutors.
Comment:
John's account of Jesus' death is highly symbolic. When Jesus gives the beloved disciple to Mary, we are invited to appreciate Mary's role in the Church: She symbolizes the Church; the beloved disciple represents all believers. As Mary mothered Jesus, she is now mother to all his followers. Furthermore, as Jesus died, he handed over his Spirit. Mary and the Spirit cooperate in begetting new children of God—almost an echo of Luke's account of Jesus' conception. Christians can trust that they will continue to experience the caring presence of Mary and Jesus' Spirit throughout their lives and throughout history.
Source: http://www.americancatholic.org/